diff options
author | Dan Williams <dan.j.williams@intel.com> | 2011-05-10 05:28:45 -0400 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2011-07-03 07:04:47 -0400 |
commit | f1f52e75939b56c40b3d153ae99faf2720250242 (patch) | |
tree | 9c5ba4f8bb6a589c6a038dac5bbba280f9de3ebe | |
parent | 3bff9d54ecba84e538da822349a9a6fd6e534539 (diff) |
isci: uplevel request infrastructure
* Consolidate tiny header files
* Move files out of core/ (drop core/scic_sds_ prefix)
* Merge core/scic_sds_request.[ch] into request.[ch]
* Cleanup request.c namespace (clean forward declarations and global
namespace pollution)
Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
27 files changed, 2194 insertions, 3198 deletions
diff --git a/drivers/scsi/isci/Makefile b/drivers/scsi/isci/Makefile index cfc640f9dc3f..a7d1eb33eca2 100644 --- a/drivers/scsi/isci/Makefile +++ b/drivers/scsi/isci/Makefile | |||
@@ -7,11 +7,9 @@ isci-objs := init.o phy.o request.o sata.o \ | |||
7 | remote_node_context.o \ | 7 | remote_node_context.o \ |
8 | remote_node_table.o \ | 8 | remote_node_table.o \ |
9 | unsolicited_frame_control.o \ | 9 | unsolicited_frame_control.o \ |
10 | core/scic_sds_request.o \ | 10 | stp_request.o \ |
11 | core/scic_sds_stp_request.o \ | 11 | ssp_request.o \ |
12 | smp_request.o \ | ||
12 | core/scic_sds_port.o \ | 13 | core/scic_sds_port.o \ |
13 | core/scic_sds_port_configuration_agent.o \ | 14 | core/scic_sds_port_configuration_agent.o \ |
14 | core/scic_sds_phy.o \ | 15 | core/scic_sds_phy.o \ |
15 | core/scic_sds_ssp_request.o \ | ||
16 | core/scic_sds_smp_request.o \ | ||
17 | core/sci_util.o | ||
diff --git a/drivers/scsi/isci/core/sci_util.c b/drivers/scsi/isci/core/sci_util.c deleted file mode 100644 index 595d8da1abba..000000000000 --- a/drivers/scsi/isci/core/sci_util.c +++ /dev/null | |||
@@ -1,86 +0,0 @@ | |||
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 | |||
56 | #include <linux/kernel.h> | ||
57 | #include "sci_util.h" | ||
58 | #include "request.h" | ||
59 | |||
60 | void *scic_request_get_virt_addr(struct scic_sds_request *sci_req, dma_addr_t phys_addr) | ||
61 | { | ||
62 | struct isci_request *ireq = sci_req_to_ireq(sci_req); | ||
63 | dma_addr_t offset; | ||
64 | |||
65 | BUG_ON(phys_addr < ireq->request_daddr); | ||
66 | |||
67 | offset = phys_addr - ireq->request_daddr; | ||
68 | |||
69 | BUG_ON(offset >= sizeof(*ireq)); | ||
70 | |||
71 | return (char *)ireq + offset; | ||
72 | } | ||
73 | |||
74 | dma_addr_t scic_io_request_get_dma_addr(struct scic_sds_request *sds_request, | ||
75 | void *virt_addr) | ||
76 | { | ||
77 | struct isci_request *isci_request = sci_req_to_ireq(sds_request); | ||
78 | |||
79 | char *requested_addr = (char *)virt_addr; | ||
80 | char *base_addr = (char *)isci_request; | ||
81 | |||
82 | BUG_ON(requested_addr < base_addr); | ||
83 | BUG_ON((requested_addr - base_addr) >= sizeof(*isci_request)); | ||
84 | |||
85 | return isci_request->request_daddr + (requested_addr - base_addr); | ||
86 | } | ||
diff --git a/drivers/scsi/isci/core/sci_util.h b/drivers/scsi/isci/core/sci_util.h deleted file mode 100644 index 0f9dd0fe1266..000000000000 --- a/drivers/scsi/isci/core/sci_util.h +++ /dev/null | |||
@@ -1,97 +0,0 @@ | |||
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 | |||
56 | #ifndef _SCI_UTIL_H_ | ||
57 | #define _SCI_UTIL_H_ | ||
58 | |||
59 | #include "scic_sds_request.h" | ||
60 | |||
61 | #define SCIC_BUILD_DWORD(char_buffer) \ | ||
62 | (\ | ||
63 | ((char_buffer)[0] << 24) \ | ||
64 | | ((char_buffer)[1] << 16) \ | ||
65 | | ((char_buffer)[2] << 8) \ | ||
66 | | ((char_buffer)[3]) \ | ||
67 | ) | ||
68 | |||
69 | #define sci_cb_make_physical_address(physical_addr, addr_upper, addr_lower) \ | ||
70 | ((physical_addr) = (addr_lower) | ((u64)addr_upper) << 32) | ||
71 | |||
72 | /** | ||
73 | * sci_swab32_cpy - convert between scsi and scu-hardware byte format | ||
74 | * @dest: receive the 4-byte endian swapped version of src | ||
75 | * @src: word aligned source buffer | ||
76 | * | ||
77 | * scu hardware handles SSP/SMP control, response, and unidentified | ||
78 | * frames in "big endian dword" order. Regardless of host endian this | ||
79 | * is always a swab32()-per-dword conversion of the standard definition, | ||
80 | * i.e. single byte fields swapped and multi-byte fields in little- | ||
81 | * endian | ||
82 | */ | ||
83 | static inline void sci_swab32_cpy(void *_dest, void *_src, ssize_t word_cnt) | ||
84 | { | ||
85 | u32 *dest = _dest, *src = _src; | ||
86 | |||
87 | while (--word_cnt >= 0) | ||
88 | dest[word_cnt] = swab32(src[word_cnt]); | ||
89 | } | ||
90 | |||
91 | void *scic_request_get_virt_addr(struct scic_sds_request *sds_request, | ||
92 | dma_addr_t phys_addr); | ||
93 | |||
94 | dma_addr_t scic_io_request_get_dma_addr(struct scic_sds_request *sds_request, | ||
95 | void *virt_addr); | ||
96 | |||
97 | #endif /* _SCI_UTIL_H_ */ | ||
diff --git a/drivers/scsi/isci/core/scic_io_request.h b/drivers/scsi/isci/core/scic_io_request.h deleted file mode 100644 index a4664cc3c576..000000000000 --- a/drivers/scsi/isci/core/scic_io_request.h +++ /dev/null | |||
@@ -1,226 +0,0 @@ | |||
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 | |||
56 | #ifndef _SCIC_IO_REQUEST_H_ | ||
57 | #define _SCIC_IO_REQUEST_H_ | ||
58 | |||
59 | #include <linux/kernel.h> | ||
60 | |||
61 | struct scic_sds_request; | ||
62 | struct scic_sds_remote_device; | ||
63 | struct scic_sds_controller; | ||
64 | |||
65 | /** | ||
66 | * This enumeration specifies the transport protocol utilized for the request. | ||
67 | * | ||
68 | * | ||
69 | */ | ||
70 | typedef enum { | ||
71 | /** | ||
72 | * This enumeration constant indicates that no protocol has yet been | ||
73 | * set. | ||
74 | */ | ||
75 | SCIC_NO_PROTOCOL, | ||
76 | |||
77 | /** | ||
78 | * This enumeration constant indicates that the protocol utilized | ||
79 | * is the Serial Management Protocol. | ||
80 | */ | ||
81 | SCIC_SMP_PROTOCOL, | ||
82 | |||
83 | /** | ||
84 | * This enumeration constant indicates that the protocol utilized | ||
85 | * is the Serial SCSI Protocol. | ||
86 | */ | ||
87 | SCIC_SSP_PROTOCOL, | ||
88 | |||
89 | /** | ||
90 | * This enumeration constant indicates that the protocol utilized | ||
91 | * is the Serial-ATA Tunneling Protocol. | ||
92 | */ | ||
93 | SCIC_STP_PROTOCOL | ||
94 | |||
95 | } SCIC_TRANSPORT_PROTOCOL; | ||
96 | |||
97 | enum sci_status scic_io_request_construct( | ||
98 | struct scic_sds_controller *scic_controller, | ||
99 | struct scic_sds_remote_device *scic_remote_device, | ||
100 | u16 io_tag, struct scic_sds_request *sci_req); | ||
101 | |||
102 | /** | ||
103 | * scic_io_request_construct_basic_ssp() - This method is called by the SCI | ||
104 | * user to build an SSP IO request. | ||
105 | * @scic_io_request: This parameter specifies the handle to the io request | ||
106 | * object to be built. | ||
107 | * | ||
108 | * - The user must have previously called scic_io_request_construct() on the | ||
109 | * supplied IO request. Indicate if the controller successfully built the IO | ||
110 | * request. SCI_SUCCESS This value is returned if the IO request was | ||
111 | * successfully built. SCI_FAILURE_UNSUPPORTED_PROTOCOL This value is returned | ||
112 | * if the remote_device does not support the SSP protocol. | ||
113 | * SCI_FAILURE_INVALID_ASSOCIATION This value is returned if the user did not | ||
114 | * properly set the association between the SCIC IO request and the user's IO | ||
115 | * request. | ||
116 | */ | ||
117 | enum sci_status scic_io_request_construct_basic_ssp( | ||
118 | struct scic_sds_request *scic_io_request); | ||
119 | |||
120 | |||
121 | |||
122 | |||
123 | |||
124 | /** | ||
125 | * scic_io_request_construct_basic_sata() - This method is called by the SCI | ||
126 | * Core user to build an STP IO request. | ||
127 | * @scic_io_request: This parameter specifies the handle to the io request | ||
128 | * object to be built. | ||
129 | * | ||
130 | * - The user must have previously called scic_io_request_construct() on the | ||
131 | * supplied IO request. Indicate if the controller successfully built the IO | ||
132 | * request. SCI_SUCCESS This value is returned if the IO request was | ||
133 | * successfully built. SCI_FAILURE_UNSUPPORTED_PROTOCOL This value is returned | ||
134 | * if the remote_device does not support the STP protocol. | ||
135 | * SCI_FAILURE_INVALID_ASSOCIATION This value is returned if the user did not | ||
136 | * properly set the association between the SCIC IO request and the user's IO | ||
137 | * request. | ||
138 | */ | ||
139 | enum sci_status scic_io_request_construct_basic_sata( | ||
140 | struct scic_sds_request *scic_io_request); | ||
141 | |||
142 | |||
143 | |||
144 | |||
145 | /** | ||
146 | * scic_io_request_construct_smp() - This method is called by the SCI user to | ||
147 | * build an SMP IO request. | ||
148 | * @scic_io_request: This parameter specifies the handle to the io request | ||
149 | * object to be built. | ||
150 | * | ||
151 | * - The user must have previously called scic_io_request_construct() on the | ||
152 | * supplied IO request. Indicate if the controller successfully built the IO | ||
153 | * request. SCI_SUCCESS This value is returned if the IO request was | ||
154 | * successfully built. SCI_FAILURE_UNSUPPORTED_PROTOCOL This value is returned | ||
155 | * if the remote_device does not support the SMP protocol. | ||
156 | * SCI_FAILURE_INVALID_ASSOCIATION This value is returned if the user did not | ||
157 | * properly set the association between the SCIC IO request and the user's IO | ||
158 | * request. | ||
159 | */ | ||
160 | enum sci_status scic_io_request_construct_smp( | ||
161 | struct scic_sds_request *scic_io_request); | ||
162 | |||
163 | |||
164 | |||
165 | /** | ||
166 | * scic_request_get_controller_status() - This method returns the controller | ||
167 | * specific IO/Task request status. These status values are unique to the | ||
168 | * specific controller being managed by the SCIC. | ||
169 | * @io_request: the handle to the IO or task management request object for | ||
170 | * which to retrieve the status. | ||
171 | * | ||
172 | * This method returns a value indicating the controller specific request | ||
173 | * status. | ||
174 | */ | ||
175 | u32 scic_request_get_controller_status( | ||
176 | struct scic_sds_request *io_request); | ||
177 | |||
178 | /** | ||
179 | * scic_io_request_get_io_tag() - This method will return the IO tag utilized | ||
180 | * by the IO request. | ||
181 | * @scic_io_request: This parameter specifies the handle to the io request | ||
182 | * object for which to return the IO tag. | ||
183 | * | ||
184 | * An unsigned integer representing the IO tag being utilized. | ||
185 | * SCI_CONTROLLER_INVALID_IO_TAG This value is returned if the IO does not | ||
186 | * currently have an IO tag allocated to it. All return other values indicate a | ||
187 | * legitimate tag. | ||
188 | */ | ||
189 | u16 scic_io_request_get_io_tag( | ||
190 | struct scic_sds_request *scic_io_request); | ||
191 | |||
192 | |||
193 | /** | ||
194 | * scic_stp_io_request_set_ncq_tag() - This method will assign an NCQ tag to | ||
195 | * the io request object. The caller of this function must make sure that | ||
196 | * only valid NCQ tags are assigned to the io request object. | ||
197 | * @scic_io_request: This parameter specifies the handle to the io request | ||
198 | * object to which to assign the ncq tag. | ||
199 | * @ncq_tag: This parameter specifies the NCQ tag to be utilized for the | ||
200 | * supplied core IO request. It is up to the user to make sure that this is | ||
201 | * a valid NCQ tag. | ||
202 | * | ||
203 | * none This function is only valid for SATA NCQ requests. | ||
204 | */ | ||
205 | void scic_stp_io_request_set_ncq_tag( | ||
206 | struct scic_sds_request *scic_io_request, | ||
207 | u16 ncq_tag); | ||
208 | |||
209 | /** | ||
210 | * scic_io_request_get_number_of_bytes_transferred() - This method will return | ||
211 | * the number of bytes transferred from the SCU | ||
212 | * @scic_io_request: This parameter specifies the handle to the io request | ||
213 | * whose data length was not eqaul to the data length specified in the | ||
214 | * request. When the driver gets an early io completion status from the | ||
215 | * hardware, this routine should be called to get the actual number of bytes | ||
216 | * transferred | ||
217 | * | ||
218 | * The return is the number of bytes transferred when the data legth is not | ||
219 | * equal to the specified length in the io request | ||
220 | */ | ||
221 | u32 scic_io_request_get_number_of_bytes_transferred( | ||
222 | struct scic_sds_request *scic_io_request); | ||
223 | |||
224 | |||
225 | #endif /* _SCIC_IO_REQUEST_H_ */ | ||
226 | |||
diff --git a/drivers/scsi/isci/core/scic_sds_phy.c b/drivers/scsi/isci/core/scic_sds_phy.c index 6b49d94bc9cc..150509b0c69e 100644 --- a/drivers/scsi/isci/core/scic_sds_phy.c +++ b/drivers/scsi/isci/core/scic_sds_phy.c | |||
@@ -61,7 +61,6 @@ | |||
61 | #include "scic_sds_phy.h" | 61 | #include "scic_sds_phy.h" |
62 | #include "scic_sds_port.h" | 62 | #include "scic_sds_port.h" |
63 | #include "remote_node_context.h" | 63 | #include "remote_node_context.h" |
64 | #include "sci_util.h" | ||
65 | #include "scu_event_codes.h" | 64 | #include "scu_event_codes.h" |
66 | #include "timers.h" | 65 | #include "timers.h" |
67 | 66 | ||
diff --git a/drivers/scsi/isci/core/scic_sds_port.c b/drivers/scsi/isci/core/scic_sds_port.c index 652917eeead4..a9f3ce111b86 100644 --- a/drivers/scsi/isci/core/scic_sds_port.c +++ b/drivers/scsi/isci/core/scic_sds_port.c | |||
@@ -60,9 +60,9 @@ | |||
60 | #include "scic_sds_port.h" | 60 | #include "scic_sds_port.h" |
61 | #include "remote_device.h" | 61 | #include "remote_device.h" |
62 | #include "remote_node_context.h" | 62 | #include "remote_node_context.h" |
63 | #include "scic_sds_request.h" | ||
64 | #include "registers.h" | 63 | #include "registers.h" |
65 | #include "timers.h" | 64 | #include "timers.h" |
65 | #include "scu_task_context.h" | ||
66 | 66 | ||
67 | #define SCIC_SDS_PORT_MIN_TIMER_COUNT (SCI_MAX_PORTS) | 67 | #define SCIC_SDS_PORT_MIN_TIMER_COUNT (SCI_MAX_PORTS) |
68 | #define SCIC_SDS_PORT_MAX_TIMER_COUNT (SCI_MAX_PORTS) | 68 | #define SCIC_SDS_PORT_MAX_TIMER_COUNT (SCI_MAX_PORTS) |
diff --git a/drivers/scsi/isci/core/scic_sds_request.c b/drivers/scsi/isci/core/scic_sds_request.c deleted file mode 100644 index cd279601de01..000000000000 --- a/drivers/scsi/isci/core/scic_sds_request.c +++ /dev/null | |||
@@ -1,1523 +0,0 @@ | |||
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 | |||
56 | #include <scsi/sas.h> | ||
57 | #include "scic_io_request.h" | ||
58 | #include "registers.h" | ||
59 | #include "scic_sds_port.h" | ||
60 | #include "remote_device.h" | ||
61 | #include "scic_sds_request.h" | ||
62 | #include "scic_sds_smp_request.h" | ||
63 | #include "scic_sds_stp_request.h" | ||
64 | #include "unsolicited_frame_control.h" | ||
65 | #include "sci_util.h" | ||
66 | #include "scu_completion_codes.h" | ||
67 | #include "scu_task_context.h" | ||
68 | #include "request.h" | ||
69 | #include "task.h" | ||
70 | |||
71 | /* | ||
72 | * **************************************************************************** | ||
73 | * * SCIC SDS IO REQUEST CONSTANTS | ||
74 | * **************************************************************************** */ | ||
75 | |||
76 | /** | ||
77 | * | ||
78 | * | ||
79 | * We have no timer requirements for IO requests right now | ||
80 | */ | ||
81 | #define SCIC_SDS_IO_REQUEST_MINIMUM_TIMER_COUNT (0) | ||
82 | #define SCIC_SDS_IO_REQUEST_MAXIMUM_TIMER_COUNT (0) | ||
83 | |||
84 | /** | ||
85 | * This method returns the sgl element pair for the specificed sgl_pair index. | ||
86 | * @sci_req: This parameter specifies the IO request for which to retrieve | ||
87 | * the Scatter-Gather List element pair. | ||
88 | * @sgl_pair_index: This parameter specifies the index into the SGL element | ||
89 | * pair to be retrieved. | ||
90 | * | ||
91 | * This method returns a pointer to an struct scu_sgl_element_pair. | ||
92 | */ | ||
93 | static struct scu_sgl_element_pair *scic_sds_request_get_sgl_element_pair( | ||
94 | struct scic_sds_request *sci_req, | ||
95 | u32 sgl_pair_index | ||
96 | ) { | ||
97 | struct scu_task_context *task_context; | ||
98 | |||
99 | task_context = (struct scu_task_context *)sci_req->task_context_buffer; | ||
100 | |||
101 | if (sgl_pair_index == 0) { | ||
102 | return &task_context->sgl_pair_ab; | ||
103 | } else if (sgl_pair_index == 1) { | ||
104 | return &task_context->sgl_pair_cd; | ||
105 | } | ||
106 | |||
107 | return &sci_req->sg_table[sgl_pair_index - 2]; | ||
108 | } | ||
109 | |||
110 | /** | ||
111 | * This function will build the SGL list for an IO request. | ||
112 | * @sci_req: This parameter specifies the IO request for which to build | ||
113 | * the Scatter-Gather List. | ||
114 | * | ||
115 | */ | ||
116 | void scic_sds_request_build_sgl(struct scic_sds_request *sds_request) | ||
117 | { | ||
118 | struct isci_request *isci_request = sci_req_to_ireq(sds_request); | ||
119 | struct isci_host *isci_host = isci_request->isci_host; | ||
120 | struct sas_task *task = isci_request_access_task(isci_request); | ||
121 | struct scatterlist *sg = NULL; | ||
122 | dma_addr_t dma_addr; | ||
123 | u32 sg_idx = 0; | ||
124 | struct scu_sgl_element_pair *scu_sg = NULL; | ||
125 | struct scu_sgl_element_pair *prev_sg = NULL; | ||
126 | |||
127 | if (task->num_scatter > 0) { | ||
128 | sg = task->scatter; | ||
129 | |||
130 | while (sg) { | ||
131 | scu_sg = scic_sds_request_get_sgl_element_pair( | ||
132 | sds_request, | ||
133 | sg_idx); | ||
134 | |||
135 | SCU_SGL_COPY(scu_sg->A, sg); | ||
136 | |||
137 | sg = sg_next(sg); | ||
138 | |||
139 | if (sg) { | ||
140 | SCU_SGL_COPY(scu_sg->B, sg); | ||
141 | sg = sg_next(sg); | ||
142 | } else | ||
143 | SCU_SGL_ZERO(scu_sg->B); | ||
144 | |||
145 | if (prev_sg) { | ||
146 | dma_addr = | ||
147 | scic_io_request_get_dma_addr( | ||
148 | sds_request, | ||
149 | scu_sg); | ||
150 | |||
151 | prev_sg->next_pair_upper = | ||
152 | upper_32_bits(dma_addr); | ||
153 | prev_sg->next_pair_lower = | ||
154 | lower_32_bits(dma_addr); | ||
155 | } | ||
156 | |||
157 | prev_sg = scu_sg; | ||
158 | sg_idx++; | ||
159 | } | ||
160 | } else { /* handle when no sg */ | ||
161 | scu_sg = scic_sds_request_get_sgl_element_pair(sds_request, | ||
162 | sg_idx); | ||
163 | |||
164 | dma_addr = dma_map_single(&isci_host->pdev->dev, | ||
165 | task->scatter, | ||
166 | task->total_xfer_len, | ||
167 | task->data_dir); | ||
168 | |||
169 | isci_request->zero_scatter_daddr = dma_addr; | ||
170 | |||
171 | scu_sg->A.length = task->total_xfer_len; | ||
172 | scu_sg->A.address_upper = upper_32_bits(dma_addr); | ||
173 | scu_sg->A.address_lower = lower_32_bits(dma_addr); | ||
174 | } | ||
175 | |||
176 | if (scu_sg) { | ||
177 | scu_sg->next_pair_upper = 0; | ||
178 | scu_sg->next_pair_lower = 0; | ||
179 | } | ||
180 | } | ||
181 | |||
182 | static void scic_sds_ssp_io_request_assign_buffers(struct scic_sds_request *sci_req) | ||
183 | { | ||
184 | if (sci_req->was_tag_assigned_by_user == false) | ||
185 | sci_req->task_context_buffer = &sci_req->tc; | ||
186 | } | ||
187 | |||
188 | static void scic_sds_io_request_build_ssp_command_iu(struct scic_sds_request *sci_req) | ||
189 | { | ||
190 | struct ssp_cmd_iu *cmd_iu; | ||
191 | struct isci_request *ireq = sci_req_to_ireq(sci_req); | ||
192 | struct sas_task *task = isci_request_access_task(ireq); | ||
193 | |||
194 | cmd_iu = &sci_req->ssp.cmd; | ||
195 | |||
196 | memcpy(cmd_iu->LUN, task->ssp_task.LUN, 8); | ||
197 | cmd_iu->add_cdb_len = 0; | ||
198 | cmd_iu->_r_a = 0; | ||
199 | cmd_iu->_r_b = 0; | ||
200 | cmd_iu->en_fburst = 0; /* unsupported */ | ||
201 | cmd_iu->task_prio = task->ssp_task.task_prio; | ||
202 | cmd_iu->task_attr = task->ssp_task.task_attr; | ||
203 | cmd_iu->_r_c = 0; | ||
204 | |||
205 | sci_swab32_cpy(&cmd_iu->cdb, task->ssp_task.cdb, | ||
206 | sizeof(task->ssp_task.cdb) / sizeof(u32)); | ||
207 | } | ||
208 | |||
209 | static void scic_sds_task_request_build_ssp_task_iu(struct scic_sds_request *sci_req) | ||
210 | { | ||
211 | struct ssp_task_iu *task_iu; | ||
212 | struct isci_request *ireq = sci_req_to_ireq(sci_req); | ||
213 | struct sas_task *task = isci_request_access_task(ireq); | ||
214 | struct isci_tmf *isci_tmf = isci_request_access_tmf(ireq); | ||
215 | |||
216 | task_iu = &sci_req->ssp.tmf; | ||
217 | |||
218 | memset(task_iu, 0, sizeof(struct ssp_task_iu)); | ||
219 | |||
220 | memcpy(task_iu->LUN, task->ssp_task.LUN, 8); | ||
221 | |||
222 | task_iu->task_func = isci_tmf->tmf_code; | ||
223 | task_iu->task_tag = | ||
224 | (ireq->ttype == tmf_task) ? | ||
225 | isci_tmf->io_tag : | ||
226 | SCI_CONTROLLER_INVALID_IO_TAG; | ||
227 | } | ||
228 | |||
229 | /** | ||
230 | * This method is will fill in the SCU Task Context for any type of SSP request. | ||
231 | * @sci_req: | ||
232 | * @task_context: | ||
233 | * | ||
234 | */ | ||
235 | static void scu_ssp_reqeust_construct_task_context( | ||
236 | struct scic_sds_request *sds_request, | ||
237 | struct scu_task_context *task_context) | ||
238 | { | ||
239 | dma_addr_t dma_addr; | ||
240 | struct scic_sds_controller *controller; | ||
241 | struct scic_sds_remote_device *target_device; | ||
242 | struct scic_sds_port *target_port; | ||
243 | |||
244 | controller = scic_sds_request_get_controller(sds_request); | ||
245 | target_device = scic_sds_request_get_device(sds_request); | ||
246 | target_port = scic_sds_request_get_port(sds_request); | ||
247 | |||
248 | /* Fill in the TC with the its required data */ | ||
249 | task_context->abort = 0; | ||
250 | task_context->priority = 0; | ||
251 | task_context->initiator_request = 1; | ||
252 | task_context->connection_rate = target_device->connection_rate; | ||
253 | task_context->protocol_engine_index = | ||
254 | scic_sds_controller_get_protocol_engine_group(controller); | ||
255 | task_context->logical_port_index = | ||
256 | scic_sds_port_get_index(target_port); | ||
257 | task_context->protocol_type = SCU_TASK_CONTEXT_PROTOCOL_SSP; | ||
258 | task_context->valid = SCU_TASK_CONTEXT_VALID; | ||
259 | task_context->context_type = SCU_TASK_CONTEXT_TYPE; | ||
260 | |||
261 | task_context->remote_node_index = | ||
262 | scic_sds_remote_device_get_index(sds_request->target_device); | ||
263 | task_context->command_code = 0; | ||
264 | |||
265 | task_context->link_layer_control = 0; | ||
266 | task_context->do_not_dma_ssp_good_response = 1; | ||
267 | task_context->strict_ordering = 0; | ||
268 | task_context->control_frame = 0; | ||
269 | task_context->timeout_enable = 0; | ||
270 | task_context->block_guard_enable = 0; | ||
271 | |||
272 | task_context->address_modifier = 0; | ||
273 | |||
274 | /* task_context->type.ssp.tag = sci_req->io_tag; */ | ||
275 | task_context->task_phase = 0x01; | ||
276 | |||
277 | if (sds_request->was_tag_assigned_by_user) { | ||
278 | /* | ||
279 | * Build the task context now since we have already read | ||
280 | * the data | ||
281 | */ | ||
282 | sds_request->post_context = | ||
283 | (SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC | | ||
284 | (scic_sds_controller_get_protocol_engine_group( | ||
285 | controller) << | ||
286 | SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT) | | ||
287 | (scic_sds_port_get_index(target_port) << | ||
288 | SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT) | | ||
289 | scic_sds_io_tag_get_index(sds_request->io_tag)); | ||
290 | } else { | ||
291 | /* | ||
292 | * Build the task context now since we have already read | ||
293 | * the data | ||
294 | * | ||
295 | * I/O tag index is not assigned because we have to wait | ||
296 | * until we get a TCi | ||
297 | */ | ||
298 | sds_request->post_context = | ||
299 | (SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC | | ||
300 | (scic_sds_controller_get_protocol_engine_group( | ||
301 | owning_controller) << | ||
302 | SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT) | | ||
303 | (scic_sds_port_get_index(target_port) << | ||
304 | SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT)); | ||
305 | } | ||
306 | |||
307 | /* | ||
308 | * Copy the physical address for the command buffer to the | ||
309 | * SCU Task Context | ||
310 | */ | ||
311 | dma_addr = scic_io_request_get_dma_addr(sds_request, | ||
312 | &sds_request->ssp.cmd); | ||
313 | |||
314 | task_context->command_iu_upper = upper_32_bits(dma_addr); | ||
315 | task_context->command_iu_lower = lower_32_bits(dma_addr); | ||
316 | |||
317 | /* | ||
318 | * Copy the physical address for the response buffer to the | ||
319 | * SCU Task Context | ||
320 | */ | ||
321 | dma_addr = scic_io_request_get_dma_addr(sds_request, | ||
322 | &sds_request->ssp.rsp); | ||
323 | |||
324 | task_context->response_iu_upper = upper_32_bits(dma_addr); | ||
325 | task_context->response_iu_lower = lower_32_bits(dma_addr); | ||
326 | } | ||
327 | |||
328 | /** | ||
329 | * This method is will fill in the SCU Task Context for a SSP IO request. | ||
330 | * @sci_req: | ||
331 | * | ||
332 | */ | ||
333 | static void scu_ssp_io_request_construct_task_context( | ||
334 | struct scic_sds_request *sci_req, | ||
335 | enum dma_data_direction dir, | ||
336 | u32 len) | ||
337 | { | ||
338 | struct scu_task_context *task_context; | ||
339 | |||
340 | task_context = scic_sds_request_get_task_context(sci_req); | ||
341 | |||
342 | scu_ssp_reqeust_construct_task_context(sci_req, task_context); | ||
343 | |||
344 | task_context->ssp_command_iu_length = | ||
345 | sizeof(struct ssp_cmd_iu) / sizeof(u32); | ||
346 | task_context->type.ssp.frame_type = SSP_COMMAND; | ||
347 | |||
348 | switch (dir) { | ||
349 | case DMA_FROM_DEVICE: | ||
350 | case DMA_NONE: | ||
351 | default: | ||
352 | task_context->task_type = SCU_TASK_TYPE_IOREAD; | ||
353 | break; | ||
354 | case DMA_TO_DEVICE: | ||
355 | task_context->task_type = SCU_TASK_TYPE_IOWRITE; | ||
356 | break; | ||
357 | } | ||
358 | |||
359 | task_context->transfer_length_bytes = len; | ||
360 | |||
361 | if (task_context->transfer_length_bytes > 0) | ||
362 | scic_sds_request_build_sgl(sci_req); | ||
363 | } | ||
364 | |||
365 | static void scic_sds_ssp_task_request_assign_buffers(struct scic_sds_request *sci_req) | ||
366 | { | ||
367 | if (sci_req->was_tag_assigned_by_user == false) | ||
368 | sci_req->task_context_buffer = &sci_req->tc; | ||
369 | } | ||
370 | |||
371 | /** | ||
372 | * This method will fill in the SCU Task Context for a SSP Task request. The | ||
373 | * following important settings are utilized: -# priority == | ||
374 | * SCU_TASK_PRIORITY_HIGH. This ensures that the task request is issued | ||
375 | * ahead of other task destined for the same Remote Node. -# task_type == | ||
376 | * SCU_TASK_TYPE_IOREAD. This simply indicates that a normal request type | ||
377 | * (i.e. non-raw frame) is being utilized to perform task management. -# | ||
378 | * control_frame == 1. This ensures that the proper endianess is set so | ||
379 | * that the bytes are transmitted in the right order for a task frame. | ||
380 | * @sci_req: This parameter specifies the task request object being | ||
381 | * constructed. | ||
382 | * | ||
383 | */ | ||
384 | static void scu_ssp_task_request_construct_task_context( | ||
385 | struct scic_sds_request *sci_req) | ||
386 | { | ||
387 | struct scu_task_context *task_context; | ||
388 | |||
389 | task_context = scic_sds_request_get_task_context(sci_req); | ||
390 | |||
391 | scu_ssp_reqeust_construct_task_context(sci_req, task_context); | ||
392 | |||
393 | task_context->control_frame = 1; | ||
394 | task_context->priority = SCU_TASK_PRIORITY_HIGH; | ||
395 | task_context->task_type = SCU_TASK_TYPE_RAW_FRAME; | ||
396 | task_context->transfer_length_bytes = 0; | ||
397 | task_context->type.ssp.frame_type = SSP_TASK; | ||
398 | task_context->ssp_command_iu_length = | ||
399 | sizeof(struct ssp_task_iu) / sizeof(u32); | ||
400 | } | ||
401 | |||
402 | |||
403 | /** | ||
404 | * This method constructs the SSP Command IU data for this ssp passthrough | ||
405 | * comand request object. | ||
406 | * @sci_req: This parameter specifies the request object for which the SSP | ||
407 | * command information unit is being built. | ||
408 | * | ||
409 | * enum sci_status, returns invalid parameter is cdb > 16 | ||
410 | */ | ||
411 | |||
412 | |||
413 | /** | ||
414 | * This method constructs the SATA request object. | ||
415 | * @sci_req: | ||
416 | * @sat_protocol: | ||
417 | * @transfer_length: | ||
418 | * @data_direction: | ||
419 | * @copy_rx_frame: | ||
420 | * | ||
421 | * enum sci_status | ||
422 | */ | ||
423 | static enum sci_status | ||
424 | scic_io_request_construct_sata(struct scic_sds_request *sci_req, | ||
425 | u32 len, | ||
426 | enum dma_data_direction dir, | ||
427 | bool copy) | ||
428 | { | ||
429 | enum sci_status status = SCI_SUCCESS; | ||
430 | struct isci_request *ireq = sci_req_to_ireq(sci_req); | ||
431 | struct sas_task *task = isci_request_access_task(ireq); | ||
432 | |||
433 | /* check for management protocols */ | ||
434 | if (ireq->ttype == tmf_task) { | ||
435 | struct isci_tmf *tmf = isci_request_access_tmf(ireq); | ||
436 | |||
437 | if (tmf->tmf_code == isci_tmf_sata_srst_high || | ||
438 | tmf->tmf_code == isci_tmf_sata_srst_low) | ||
439 | return scic_sds_stp_soft_reset_request_construct(sci_req); | ||
440 | else { | ||
441 | dev_err(scic_to_dev(sci_req->owning_controller), | ||
442 | "%s: Request 0x%p received un-handled SAT " | ||
443 | "management protocol 0x%x.\n", | ||
444 | __func__, sci_req, tmf->tmf_code); | ||
445 | |||
446 | return SCI_FAILURE; | ||
447 | } | ||
448 | } | ||
449 | |||
450 | if (!sas_protocol_ata(task->task_proto)) { | ||
451 | dev_err(scic_to_dev(sci_req->owning_controller), | ||
452 | "%s: Non-ATA protocol in SATA path: 0x%x\n", | ||
453 | __func__, | ||
454 | task->task_proto); | ||
455 | return SCI_FAILURE; | ||
456 | |||
457 | } | ||
458 | |||
459 | /* non data */ | ||
460 | if (task->data_dir == DMA_NONE) | ||
461 | return scic_sds_stp_non_data_request_construct(sci_req); | ||
462 | |||
463 | /* NCQ */ | ||
464 | if (task->ata_task.use_ncq) | ||
465 | return scic_sds_stp_ncq_request_construct(sci_req, len, dir); | ||
466 | |||
467 | /* DMA */ | ||
468 | if (task->ata_task.dma_xfer) | ||
469 | return scic_sds_stp_udma_request_construct(sci_req, len, dir); | ||
470 | else /* PIO */ | ||
471 | return scic_sds_stp_pio_request_construct(sci_req, copy); | ||
472 | |||
473 | return status; | ||
474 | } | ||
475 | |||
476 | enum sci_status scic_io_request_construct_basic_ssp( | ||
477 | struct scic_sds_request *sci_req) | ||
478 | { | ||
479 | struct isci_request *ireq = sci_req_to_ireq(sci_req); | ||
480 | struct sas_task *task = isci_request_access_task(ireq); | ||
481 | |||
482 | sci_req->protocol = SCIC_SSP_PROTOCOL; | ||
483 | |||
484 | scu_ssp_io_request_construct_task_context(sci_req, | ||
485 | task->data_dir, | ||
486 | task->total_xfer_len); | ||
487 | |||
488 | scic_sds_io_request_build_ssp_command_iu(sci_req); | ||
489 | |||
490 | sci_base_state_machine_change_state( | ||
491 | &sci_req->state_machine, | ||
492 | SCI_BASE_REQUEST_STATE_CONSTRUCTED); | ||
493 | |||
494 | return SCI_SUCCESS; | ||
495 | } | ||
496 | |||
497 | |||
498 | enum sci_status scic_task_request_construct_ssp( | ||
499 | struct scic_sds_request *sci_req) | ||
500 | { | ||
501 | /* Construct the SSP Task SCU Task Context */ | ||
502 | scu_ssp_task_request_construct_task_context(sci_req); | ||
503 | |||
504 | /* Fill in the SSP Task IU */ | ||
505 | scic_sds_task_request_build_ssp_task_iu(sci_req); | ||
506 | |||
507 | sci_base_state_machine_change_state(&sci_req->state_machine, | ||
508 | SCI_BASE_REQUEST_STATE_CONSTRUCTED); | ||
509 | |||
510 | return SCI_SUCCESS; | ||
511 | } | ||
512 | |||
513 | |||
514 | enum sci_status scic_io_request_construct_basic_sata( | ||
515 | struct scic_sds_request *sci_req) | ||
516 | { | ||
517 | enum sci_status status; | ||
518 | struct scic_sds_stp_request *stp_req; | ||
519 | bool copy = false; | ||
520 | struct isci_request *isci_request = sci_req_to_ireq(sci_req); | ||
521 | struct sas_task *task = isci_request_access_task(isci_request); | ||
522 | |||
523 | stp_req = &sci_req->stp.req; | ||
524 | sci_req->protocol = SCIC_STP_PROTOCOL; | ||
525 | |||
526 | copy = (task->data_dir == DMA_NONE) ? false : true; | ||
527 | |||
528 | status = scic_io_request_construct_sata(sci_req, | ||
529 | task->total_xfer_len, | ||
530 | task->data_dir, | ||
531 | copy); | ||
532 | |||
533 | if (status == SCI_SUCCESS) | ||
534 | sci_base_state_machine_change_state(&sci_req->state_machine, | ||
535 | SCI_BASE_REQUEST_STATE_CONSTRUCTED); | ||
536 | |||
537 | return status; | ||
538 | } | ||
539 | |||
540 | |||
541 | enum sci_status scic_task_request_construct_sata(struct scic_sds_request *sci_req) | ||
542 | { | ||
543 | enum sci_status status = SCI_SUCCESS; | ||
544 | struct isci_request *ireq = sci_req_to_ireq(sci_req); | ||
545 | |||
546 | /* check for management protocols */ | ||
547 | if (ireq->ttype == tmf_task) { | ||
548 | struct isci_tmf *tmf = isci_request_access_tmf(ireq); | ||
549 | |||
550 | if (tmf->tmf_code == isci_tmf_sata_srst_high || | ||
551 | tmf->tmf_code == isci_tmf_sata_srst_low) { | ||
552 | status = scic_sds_stp_soft_reset_request_construct(sci_req); | ||
553 | } else { | ||
554 | dev_err(scic_to_dev(sci_req->owning_controller), | ||
555 | "%s: Request 0x%p received un-handled SAT " | ||
556 | "Protocol 0x%x.\n", | ||
557 | __func__, sci_req, tmf->tmf_code); | ||
558 | |||
559 | return SCI_FAILURE; | ||
560 | } | ||
561 | } | ||
562 | |||
563 | if (status == SCI_SUCCESS) | ||
564 | sci_base_state_machine_change_state( | ||
565 | &sci_req->state_machine, | ||
566 | SCI_BASE_REQUEST_STATE_CONSTRUCTED); | ||
567 | |||
568 | return status; | ||
569 | } | ||
570 | |||
571 | |||
572 | u16 scic_io_request_get_io_tag( | ||
573 | struct scic_sds_request *sci_req) | ||
574 | { | ||
575 | return sci_req->io_tag; | ||
576 | } | ||
577 | |||
578 | |||
579 | u32 scic_request_get_controller_status( | ||
580 | struct scic_sds_request *sci_req) | ||
581 | { | ||
582 | return sci_req->scu_status; | ||
583 | } | ||
584 | |||
585 | #define SCU_TASK_CONTEXT_SRAM 0x200000 | ||
586 | u32 scic_io_request_get_number_of_bytes_transferred( | ||
587 | struct scic_sds_request *scic_sds_request) | ||
588 | { | ||
589 | struct scic_sds_controller *scic = scic_sds_request->owning_controller; | ||
590 | u32 ret_val = 0; | ||
591 | |||
592 | if (readl(&scic->smu_registers->address_modifier) == 0) { | ||
593 | void __iomem *scu_reg_base = scic->scu_registers; | ||
594 | /* | ||
595 | * get the bytes of data from the Address == BAR1 + 20002Ch + (256*TCi) where | ||
596 | * BAR1 is the scu_registers | ||
597 | * 0x20002C = 0x200000 + 0x2c | ||
598 | * = start of task context SRAM + offset of (type.ssp.data_offset) | ||
599 | * TCi is the io_tag of struct scic_sds_request */ | ||
600 | ret_val = readl(scu_reg_base + | ||
601 | (SCU_TASK_CONTEXT_SRAM + offsetof(struct scu_task_context, type.ssp.data_offset)) + | ||
602 | ((sizeof(struct scu_task_context)) * scic_sds_io_tag_get_index(scic_sds_request->io_tag))); | ||
603 | } | ||
604 | |||
605 | return ret_val; | ||
606 | } | ||
607 | |||
608 | |||
609 | /* | ||
610 | * **************************************************************************** | ||
611 | * * SCIC SDS Interface Implementation | ||
612 | * **************************************************************************** */ | ||
613 | |||
614 | enum sci_status | ||
615 | scic_sds_request_start(struct scic_sds_request *request) | ||
616 | { | ||
617 | if (request->device_sequence != | ||
618 | scic_sds_remote_device_get_sequence(request->target_device)) | ||
619 | return SCI_FAILURE; | ||
620 | |||
621 | if (request->state_handlers->start_handler) | ||
622 | return request->state_handlers->start_handler(request); | ||
623 | |||
624 | dev_warn(scic_to_dev(request->owning_controller), | ||
625 | "%s: SCIC IO Request requested to start while in wrong " | ||
626 | "state %d\n", | ||
627 | __func__, | ||
628 | sci_base_state_machine_get_state(&request->state_machine)); | ||
629 | |||
630 | return SCI_FAILURE_INVALID_STATE; | ||
631 | } | ||
632 | |||
633 | enum sci_status | ||
634 | scic_sds_io_request_terminate(struct scic_sds_request *request) | ||
635 | { | ||
636 | if (request->state_handlers->abort_handler) | ||
637 | return request->state_handlers->abort_handler(request); | ||
638 | |||
639 | dev_warn(scic_to_dev(request->owning_controller), | ||
640 | "%s: SCIC IO Request requested to abort while in wrong " | ||
641 | "state %d\n", | ||
642 | __func__, | ||
643 | sci_base_state_machine_get_state(&request->state_machine)); | ||
644 | |||
645 | return SCI_FAILURE_INVALID_STATE; | ||
646 | } | ||
647 | |||
648 | enum sci_status | ||
649 | scic_sds_io_request_complete(struct scic_sds_request *request) | ||
650 | { | ||
651 | if (request->state_handlers->complete_handler) | ||
652 | return request->state_handlers->complete_handler(request); | ||
653 | |||
654 | dev_warn(scic_to_dev(request->owning_controller), | ||
655 | "%s: SCIC IO Request requested to complete while in wrong " | ||
656 | "state %d\n", | ||
657 | __func__, | ||
658 | sci_base_state_machine_get_state(&request->state_machine)); | ||
659 | |||
660 | return SCI_FAILURE_INVALID_STATE; | ||
661 | } | ||
662 | |||
663 | enum sci_status scic_sds_io_request_event_handler( | ||
664 | struct scic_sds_request *request, | ||
665 | u32 event_code) | ||
666 | { | ||
667 | if (request->state_handlers->event_handler) | ||
668 | return request->state_handlers->event_handler(request, event_code); | ||
669 | |||
670 | dev_warn(scic_to_dev(request->owning_controller), | ||
671 | "%s: SCIC IO Request given event code notification %x while " | ||
672 | "in wrong state %d\n", | ||
673 | __func__, | ||
674 | event_code, | ||
675 | sci_base_state_machine_get_state(&request->state_machine)); | ||
676 | |||
677 | return SCI_FAILURE_INVALID_STATE; | ||
678 | } | ||
679 | |||
680 | enum sci_status | ||
681 | scic_sds_io_request_tc_completion(struct scic_sds_request *request, u32 completion_code) | ||
682 | { | ||
683 | if (request->state_machine.current_state_id == SCI_BASE_REQUEST_STATE_STARTED && | ||
684 | request->has_started_substate_machine == false) | ||
685 | return scic_sds_request_started_state_tc_completion_handler(request, completion_code); | ||
686 | else if (request->state_handlers->tc_completion_handler) | ||
687 | return request->state_handlers->tc_completion_handler(request, completion_code); | ||
688 | |||
689 | dev_warn(scic_to_dev(request->owning_controller), | ||
690 | "%s: SCIC IO Request given task completion notification %x " | ||
691 | "while in wrong state %d\n", | ||
692 | __func__, | ||
693 | completion_code, | ||
694 | sci_base_state_machine_get_state(&request->state_machine)); | ||
695 | |||
696 | return SCI_FAILURE_INVALID_STATE; | ||
697 | |||
698 | } | ||
699 | |||
700 | |||
701 | /** | ||
702 | * | ||
703 | * @sci_req: The SCIC_SDS_IO_REQUEST_T object for which the start | ||
704 | * operation is to be executed. | ||
705 | * @frame_index: The frame index returned by the hardware for the reqeust | ||
706 | * object. | ||
707 | * | ||
708 | * This method invokes the core state frame handler for the | ||
709 | * SCIC_SDS_IO_REQUEST_T object. enum sci_status | ||
710 | */ | ||
711 | enum sci_status scic_sds_io_request_frame_handler( | ||
712 | struct scic_sds_request *request, | ||
713 | u32 frame_index) | ||
714 | { | ||
715 | if (request->state_handlers->frame_handler) | ||
716 | return request->state_handlers->frame_handler(request, frame_index); | ||
717 | |||
718 | dev_warn(scic_to_dev(request->owning_controller), | ||
719 | "%s: SCIC IO Request given unexpected frame %x while in " | ||
720 | "state %d\n", | ||
721 | __func__, | ||
722 | frame_index, | ||
723 | sci_base_state_machine_get_state(&request->state_machine)); | ||
724 | |||
725 | scic_sds_controller_release_frame(request->owning_controller, frame_index); | ||
726 | return SCI_FAILURE_INVALID_STATE; | ||
727 | } | ||
728 | |||
729 | /* | ||
730 | * This function copies response data for requests returning response data | ||
731 | * instead of sense data. | ||
732 | * @sci_req: This parameter specifies the request object for which to copy | ||
733 | * the response data. | ||
734 | */ | ||
735 | void scic_sds_io_request_copy_response(struct scic_sds_request *sci_req) | ||
736 | { | ||
737 | void *resp_buf; | ||
738 | u32 len; | ||
739 | struct ssp_response_iu *ssp_response; | ||
740 | struct isci_request *ireq = sci_req_to_ireq(sci_req); | ||
741 | struct isci_tmf *isci_tmf = isci_request_access_tmf(ireq); | ||
742 | |||
743 | ssp_response = &sci_req->ssp.rsp; | ||
744 | |||
745 | resp_buf = &isci_tmf->resp.resp_iu; | ||
746 | |||
747 | len = min_t(u32, | ||
748 | SSP_RESP_IU_MAX_SIZE, | ||
749 | be32_to_cpu(ssp_response->response_data_len)); | ||
750 | |||
751 | memcpy(resp_buf, ssp_response->resp_data, len); | ||
752 | } | ||
753 | |||
754 | /* | ||
755 | * ***************************************************************************** | ||
756 | * * CONSTRUCTED STATE HANDLERS | ||
757 | * ***************************************************************************** */ | ||
758 | |||
759 | /* | ||
760 | * This method implements the action taken when a constructed | ||
761 | * SCIC_SDS_IO_REQUEST_T object receives a scic_sds_request_start() request. | ||
762 | * This method will, if necessary, allocate a TCi for the io request object and | ||
763 | * then will, if necessary, copy the constructed TC data into the actual TC | ||
764 | * buffer. If everything is successful the post context field is updated with | ||
765 | * the TCi so the controller can post the request to the hardware. enum sci_status | ||
766 | * SCI_SUCCESS SCI_FAILURE_INSUFFICIENT_RESOURCES | ||
767 | */ | ||
768 | static enum sci_status scic_sds_request_constructed_state_start_handler( | ||
769 | struct scic_sds_request *request) | ||
770 | { | ||
771 | struct scu_task_context *task_context; | ||
772 | |||
773 | if (request->io_tag == SCI_CONTROLLER_INVALID_IO_TAG) { | ||
774 | request->io_tag = | ||
775 | scic_controller_allocate_io_tag(request->owning_controller); | ||
776 | } | ||
777 | |||
778 | /* Record the IO Tag in the request */ | ||
779 | if (request->io_tag != SCI_CONTROLLER_INVALID_IO_TAG) { | ||
780 | task_context = request->task_context_buffer; | ||
781 | |||
782 | task_context->task_index = scic_sds_io_tag_get_index(request->io_tag); | ||
783 | |||
784 | switch (task_context->protocol_type) { | ||
785 | case SCU_TASK_CONTEXT_PROTOCOL_SMP: | ||
786 | case SCU_TASK_CONTEXT_PROTOCOL_SSP: | ||
787 | /* SSP/SMP Frame */ | ||
788 | task_context->type.ssp.tag = request->io_tag; | ||
789 | task_context->type.ssp.target_port_transfer_tag = 0xFFFF; | ||
790 | break; | ||
791 | |||
792 | case SCU_TASK_CONTEXT_PROTOCOL_STP: | ||
793 | /* | ||
794 | * STP/SATA Frame | ||
795 | * task_context->type.stp.ncq_tag = request->ncq_tag; */ | ||
796 | break; | ||
797 | |||
798 | case SCU_TASK_CONTEXT_PROTOCOL_NONE: | ||
799 | /* / @todo When do we set no protocol type? */ | ||
800 | break; | ||
801 | |||
802 | default: | ||
803 | /* This should never happen since we build the IO requests */ | ||
804 | break; | ||
805 | } | ||
806 | |||
807 | /* | ||
808 | * Check to see if we need to copy the task context buffer | ||
809 | * or have been building into the task context buffer */ | ||
810 | if (request->was_tag_assigned_by_user == false) { | ||
811 | scic_sds_controller_copy_task_context( | ||
812 | request->owning_controller, request); | ||
813 | } | ||
814 | |||
815 | /* Add to the post_context the io tag value */ | ||
816 | request->post_context |= scic_sds_io_tag_get_index(request->io_tag); | ||
817 | |||
818 | /* Everything is good go ahead and change state */ | ||
819 | sci_base_state_machine_change_state(&request->state_machine, | ||
820 | SCI_BASE_REQUEST_STATE_STARTED); | ||
821 | |||
822 | return SCI_SUCCESS; | ||
823 | } | ||
824 | |||
825 | return SCI_FAILURE_INSUFFICIENT_RESOURCES; | ||
826 | } | ||
827 | |||
828 | /* | ||
829 | * This method implements the action to be taken when an SCIC_SDS_IO_REQUEST_T | ||
830 | * object receives a scic_sds_request_terminate() request. Since the request | ||
831 | * has not yet been posted to the hardware the request transitions to the | ||
832 | * completed state. enum sci_status SCI_SUCCESS | ||
833 | */ | ||
834 | static enum sci_status scic_sds_request_constructed_state_abort_handler( | ||
835 | struct scic_sds_request *request) | ||
836 | { | ||
837 | /* | ||
838 | * This request has been terminated by the user make sure that the correct | ||
839 | * status code is returned */ | ||
840 | scic_sds_request_set_status(request, | ||
841 | SCU_TASK_DONE_TASK_ABORT, | ||
842 | SCI_FAILURE_IO_TERMINATED); | ||
843 | |||
844 | sci_base_state_machine_change_state(&request->state_machine, | ||
845 | SCI_BASE_REQUEST_STATE_COMPLETED); | ||
846 | return SCI_SUCCESS; | ||
847 | } | ||
848 | |||
849 | /* | ||
850 | * ***************************************************************************** | ||
851 | * * STARTED STATE HANDLERS | ||
852 | * ***************************************************************************** */ | ||
853 | |||
854 | /* | ||
855 | * This method implements the action to be taken when an SCIC_SDS_IO_REQUEST_T | ||
856 | * object receives a scic_sds_request_terminate() request. Since the request | ||
857 | * has been posted to the hardware the io request state is changed to the | ||
858 | * aborting state. enum sci_status SCI_SUCCESS | ||
859 | */ | ||
860 | enum sci_status scic_sds_request_started_state_abort_handler( | ||
861 | struct scic_sds_request *request) | ||
862 | { | ||
863 | if (request->has_started_substate_machine) | ||
864 | sci_base_state_machine_stop(&request->started_substate_machine); | ||
865 | |||
866 | sci_base_state_machine_change_state(&request->state_machine, | ||
867 | SCI_BASE_REQUEST_STATE_ABORTING); | ||
868 | return SCI_SUCCESS; | ||
869 | } | ||
870 | |||
871 | /* | ||
872 | * scic_sds_request_started_state_tc_completion_handler() - This method process | ||
873 | * TC (task context) completions for normal IO request (i.e. Task/Abort | ||
874 | * Completions of type 0). This method will update the | ||
875 | * SCIC_SDS_IO_REQUEST_T::status field. | ||
876 | * @sci_req: This parameter specifies the request for which a completion | ||
877 | * occurred. | ||
878 | * @completion_code: This parameter specifies the completion code received from | ||
879 | * the SCU. | ||
880 | * | ||
881 | */ | ||
882 | enum sci_status | ||
883 | scic_sds_request_started_state_tc_completion_handler( | ||
884 | struct scic_sds_request *sci_req, | ||
885 | u32 completion_code) | ||
886 | { | ||
887 | u8 datapres; | ||
888 | struct ssp_response_iu *resp_iu; | ||
889 | |||
890 | /* | ||
891 | * TODO: Any SDMA return code of other than 0 is bad | ||
892 | * decode 0x003C0000 to determine SDMA status | ||
893 | */ | ||
894 | switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) { | ||
895 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD): | ||
896 | scic_sds_request_set_status(sci_req, | ||
897 | SCU_TASK_DONE_GOOD, | ||
898 | SCI_SUCCESS); | ||
899 | break; | ||
900 | |||
901 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_EARLY_RESP): | ||
902 | { | ||
903 | /* | ||
904 | * There are times when the SCU hardware will return an early | ||
905 | * response because the io request specified more data than is | ||
906 | * returned by the target device (mode pages, inquiry data, | ||
907 | * etc.). We must check the response stats to see if this is | ||
908 | * truly a failed request or a good request that just got | ||
909 | * completed early. | ||
910 | */ | ||
911 | struct ssp_response_iu *resp = &sci_req->ssp.rsp; | ||
912 | ssize_t word_cnt = SSP_RESP_IU_MAX_SIZE / sizeof(u32); | ||
913 | |||
914 | sci_swab32_cpy(&sci_req->ssp.rsp, | ||
915 | &sci_req->ssp.rsp, | ||
916 | word_cnt); | ||
917 | |||
918 | if (resp->status == 0) { | ||
919 | scic_sds_request_set_status( | ||
920 | sci_req, | ||
921 | SCU_TASK_DONE_GOOD, | ||
922 | SCI_SUCCESS_IO_DONE_EARLY); | ||
923 | } else { | ||
924 | scic_sds_request_set_status( | ||
925 | sci_req, | ||
926 | SCU_TASK_DONE_CHECK_RESPONSE, | ||
927 | SCI_FAILURE_IO_RESPONSE_VALID); | ||
928 | } | ||
929 | } | ||
930 | break; | ||
931 | |||
932 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_CHECK_RESPONSE): | ||
933 | { | ||
934 | ssize_t word_cnt = SSP_RESP_IU_MAX_SIZE / sizeof(u32); | ||
935 | |||
936 | sci_swab32_cpy(&sci_req->ssp.rsp, | ||
937 | &sci_req->ssp.rsp, | ||
938 | word_cnt); | ||
939 | |||
940 | scic_sds_request_set_status(sci_req, | ||
941 | SCU_TASK_DONE_CHECK_RESPONSE, | ||
942 | SCI_FAILURE_IO_RESPONSE_VALID); | ||
943 | break; | ||
944 | } | ||
945 | |||
946 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_RESP_LEN_ERR): | ||
947 | /* | ||
948 | * / @todo With TASK_DONE_RESP_LEN_ERR is the response frame | ||
949 | * guaranteed to be received before this completion status is | ||
950 | * posted? | ||
951 | */ | ||
952 | resp_iu = &sci_req->ssp.rsp; | ||
953 | datapres = resp_iu->datapres; | ||
954 | |||
955 | if ((datapres == 0x01) || (datapres == 0x02)) { | ||
956 | scic_sds_request_set_status( | ||
957 | sci_req, | ||
958 | SCU_TASK_DONE_CHECK_RESPONSE, | ||
959 | SCI_FAILURE_IO_RESPONSE_VALID); | ||
960 | } else | ||
961 | scic_sds_request_set_status( | ||
962 | sci_req, SCU_TASK_DONE_GOOD, SCI_SUCCESS); | ||
963 | break; | ||
964 | |||
965 | /* only stp device gets suspended. */ | ||
966 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_ACK_NAK_TO): | ||
967 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_LL_PERR): | ||
968 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_NAK_ERR): | ||
969 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_DATA_LEN_ERR): | ||
970 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_LL_ABORT_ERR): | ||
971 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_XR_WD_LEN): | ||
972 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_MAX_PLD_ERR): | ||
973 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_UNEXP_RESP): | ||
974 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_UNEXP_SDBFIS): | ||
975 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_REG_ERR): | ||
976 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SDB_ERR): | ||
977 | if (sci_req->protocol == SCIC_STP_PROTOCOL) { | ||
978 | scic_sds_request_set_status( | ||
979 | sci_req, | ||
980 | SCU_GET_COMPLETION_TL_STATUS(completion_code) >> | ||
981 | SCU_COMPLETION_TL_STATUS_SHIFT, | ||
982 | SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED); | ||
983 | } else { | ||
984 | scic_sds_request_set_status( | ||
985 | sci_req, | ||
986 | SCU_GET_COMPLETION_TL_STATUS(completion_code) >> | ||
987 | SCU_COMPLETION_TL_STATUS_SHIFT, | ||
988 | SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR); | ||
989 | } | ||
990 | break; | ||
991 | |||
992 | /* both stp/ssp device gets suspended */ | ||
993 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_LF_ERR): | ||
994 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_WRONG_DESTINATION): | ||
995 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_RESERVED_ABANDON_1): | ||
996 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_RESERVED_ABANDON_2): | ||
997 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_RESERVED_ABANDON_3): | ||
998 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_BAD_DESTINATION): | ||
999 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_ZONE_VIOLATION): | ||
1000 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_STP_RESOURCES_BUSY): | ||
1001 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_PROTOCOL_NOT_SUPPORTED): | ||
1002 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_CONNECTION_RATE_NOT_SUPPORTED): | ||
1003 | scic_sds_request_set_status( | ||
1004 | sci_req, | ||
1005 | SCU_GET_COMPLETION_TL_STATUS(completion_code) >> | ||
1006 | SCU_COMPLETION_TL_STATUS_SHIFT, | ||
1007 | SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED); | ||
1008 | break; | ||
1009 | |||
1010 | /* neither ssp nor stp gets suspended. */ | ||
1011 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_NAK_CMD_ERR): | ||
1012 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_UNEXP_XR): | ||
1013 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_XR_IU_LEN_ERR): | ||
1014 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SDMA_ERR): | ||
1015 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_OFFSET_ERR): | ||
1016 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_EXCESS_DATA): | ||
1017 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SMP_RESP_TO_ERR): | ||
1018 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SMP_UFI_ERR): | ||
1019 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SMP_FRM_TYPE_ERR): | ||
1020 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SMP_LL_RX_ERR): | ||
1021 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_UNEXP_DATA): | ||
1022 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_OPEN_FAIL): | ||
1023 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_VIIT_ENTRY_NV): | ||
1024 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_IIT_ENTRY_NV): | ||
1025 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_RNCNV_OUTBOUND): | ||
1026 | default: | ||
1027 | scic_sds_request_set_status( | ||
1028 | sci_req, | ||
1029 | SCU_GET_COMPLETION_TL_STATUS(completion_code) >> | ||
1030 | SCU_COMPLETION_TL_STATUS_SHIFT, | ||
1031 | SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR); | ||
1032 | break; | ||
1033 | } | ||
1034 | |||
1035 | /* | ||
1036 | * TODO: This is probably wrong for ACK/NAK timeout conditions | ||
1037 | */ | ||
1038 | |||
1039 | /* In all cases we will treat this as the completion of the IO req. */ | ||
1040 | sci_base_state_machine_change_state( | ||
1041 | &sci_req->state_machine, | ||
1042 | SCI_BASE_REQUEST_STATE_COMPLETED); | ||
1043 | return SCI_SUCCESS; | ||
1044 | } | ||
1045 | |||
1046 | /* | ||
1047 | * This method implements the action to be taken when an SCIC_SDS_IO_REQUEST_T | ||
1048 | * object receives a scic_sds_request_frame_handler() request. This method | ||
1049 | * first determines the frame type received. If this is a response frame then | ||
1050 | * the response data is copied to the io request response buffer for processing | ||
1051 | * at completion time. If the frame type is not a response buffer an error is | ||
1052 | * logged. enum sci_status SCI_SUCCESS SCI_FAILURE_INVALID_PARAMETER_VALUE | ||
1053 | */ | ||
1054 | static enum sci_status | ||
1055 | scic_sds_request_started_state_frame_handler(struct scic_sds_request *sci_req, | ||
1056 | u32 frame_index) | ||
1057 | { | ||
1058 | enum sci_status status; | ||
1059 | u32 *frame_header; | ||
1060 | struct ssp_frame_hdr ssp_hdr; | ||
1061 | ssize_t word_cnt; | ||
1062 | |||
1063 | status = scic_sds_unsolicited_frame_control_get_header( | ||
1064 | &(scic_sds_request_get_controller(sci_req)->uf_control), | ||
1065 | frame_index, | ||
1066 | (void **)&frame_header); | ||
1067 | |||
1068 | word_cnt = sizeof(struct ssp_frame_hdr) / sizeof(u32); | ||
1069 | sci_swab32_cpy(&ssp_hdr, frame_header, word_cnt); | ||
1070 | |||
1071 | if (ssp_hdr.frame_type == SSP_RESPONSE) { | ||
1072 | struct ssp_response_iu *resp_iu; | ||
1073 | ssize_t word_cnt = SSP_RESP_IU_MAX_SIZE / sizeof(u32); | ||
1074 | |||
1075 | status = scic_sds_unsolicited_frame_control_get_buffer( | ||
1076 | &(scic_sds_request_get_controller(sci_req)->uf_control), | ||
1077 | frame_index, | ||
1078 | (void **)&resp_iu); | ||
1079 | |||
1080 | sci_swab32_cpy(&sci_req->ssp.rsp, | ||
1081 | resp_iu, word_cnt); | ||
1082 | |||
1083 | resp_iu = &sci_req->ssp.rsp; | ||
1084 | |||
1085 | if ((resp_iu->datapres == 0x01) || | ||
1086 | (resp_iu->datapres == 0x02)) { | ||
1087 | scic_sds_request_set_status( | ||
1088 | sci_req, | ||
1089 | SCU_TASK_DONE_CHECK_RESPONSE, | ||
1090 | SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR); | ||
1091 | } else | ||
1092 | scic_sds_request_set_status( | ||
1093 | sci_req, SCU_TASK_DONE_GOOD, SCI_SUCCESS); | ||
1094 | } else { | ||
1095 | /* This was not a response frame why did it get forwarded? */ | ||
1096 | dev_err(scic_to_dev(sci_req->owning_controller), | ||
1097 | "%s: SCIC IO Request 0x%p received unexpected " | ||
1098 | "frame %d type 0x%02x\n", | ||
1099 | __func__, | ||
1100 | sci_req, | ||
1101 | frame_index, | ||
1102 | ssp_hdr.frame_type); | ||
1103 | } | ||
1104 | |||
1105 | /* | ||
1106 | * In any case we are done with this frame buffer return it to the | ||
1107 | * controller | ||
1108 | */ | ||
1109 | scic_sds_controller_release_frame( | ||
1110 | sci_req->owning_controller, frame_index); | ||
1111 | |||
1112 | return SCI_SUCCESS; | ||
1113 | } | ||
1114 | |||
1115 | /* | ||
1116 | * ***************************************************************************** | ||
1117 | * * COMPLETED STATE HANDLERS | ||
1118 | * ***************************************************************************** */ | ||
1119 | |||
1120 | |||
1121 | /* | ||
1122 | * This method implements the action to be taken when an SCIC_SDS_IO_REQUEST_T | ||
1123 | * object receives a scic_sds_request_complete() request. This method frees up | ||
1124 | * any io request resources that have been allocated and transitions the | ||
1125 | * request to its final state. Consider stopping the state machine instead of | ||
1126 | * transitioning to the final state? enum sci_status SCI_SUCCESS | ||
1127 | */ | ||
1128 | static enum sci_status scic_sds_request_completed_state_complete_handler( | ||
1129 | struct scic_sds_request *request) | ||
1130 | { | ||
1131 | if (request->was_tag_assigned_by_user != true) { | ||
1132 | scic_controller_free_io_tag( | ||
1133 | request->owning_controller, request->io_tag); | ||
1134 | } | ||
1135 | |||
1136 | if (request->saved_rx_frame_index != SCU_INVALID_FRAME_INDEX) { | ||
1137 | scic_sds_controller_release_frame( | ||
1138 | request->owning_controller, request->saved_rx_frame_index); | ||
1139 | } | ||
1140 | |||
1141 | sci_base_state_machine_change_state(&request->state_machine, | ||
1142 | SCI_BASE_REQUEST_STATE_FINAL); | ||
1143 | return SCI_SUCCESS; | ||
1144 | } | ||
1145 | |||
1146 | /* | ||
1147 | * ***************************************************************************** | ||
1148 | * * ABORTING STATE HANDLERS | ||
1149 | * ***************************************************************************** */ | ||
1150 | |||
1151 | /* | ||
1152 | * This method implements the action to be taken when an SCIC_SDS_IO_REQUEST_T | ||
1153 | * object receives a scic_sds_request_terminate() request. This method is the | ||
1154 | * io request aborting state abort handlers. On receipt of a multiple | ||
1155 | * terminate requests the io request will transition to the completed state. | ||
1156 | * This should not happen in normal operation. enum sci_status SCI_SUCCESS | ||
1157 | */ | ||
1158 | static enum sci_status scic_sds_request_aborting_state_abort_handler( | ||
1159 | struct scic_sds_request *request) | ||
1160 | { | ||
1161 | sci_base_state_machine_change_state(&request->state_machine, | ||
1162 | SCI_BASE_REQUEST_STATE_COMPLETED); | ||
1163 | return SCI_SUCCESS; | ||
1164 | } | ||
1165 | |||
1166 | /* | ||
1167 | * This method implements the action to be taken when an SCIC_SDS_IO_REQUEST_T | ||
1168 | * object receives a scic_sds_request_task_completion() request. This method | ||
1169 | * decodes the completion type waiting for the abort task complete | ||
1170 | * notification. When the abort task complete is received the io request | ||
1171 | * transitions to the completed state. enum sci_status SCI_SUCCESS | ||
1172 | */ | ||
1173 | static enum sci_status scic_sds_request_aborting_state_tc_completion_handler( | ||
1174 | struct scic_sds_request *sci_req, | ||
1175 | u32 completion_code) | ||
1176 | { | ||
1177 | switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) { | ||
1178 | case (SCU_TASK_DONE_GOOD << SCU_COMPLETION_TL_STATUS_SHIFT): | ||
1179 | case (SCU_TASK_DONE_TASK_ABORT << SCU_COMPLETION_TL_STATUS_SHIFT): | ||
1180 | scic_sds_request_set_status( | ||
1181 | sci_req, SCU_TASK_DONE_TASK_ABORT, SCI_FAILURE_IO_TERMINATED | ||
1182 | ); | ||
1183 | |||
1184 | sci_base_state_machine_change_state(&sci_req->state_machine, | ||
1185 | SCI_BASE_REQUEST_STATE_COMPLETED); | ||
1186 | break; | ||
1187 | |||
1188 | default: | ||
1189 | /* | ||
1190 | * Unless we get some strange error wait for the task abort to complete | ||
1191 | * TODO: Should there be a state change for this completion? */ | ||
1192 | break; | ||
1193 | } | ||
1194 | |||
1195 | return SCI_SUCCESS; | ||
1196 | } | ||
1197 | |||
1198 | /* | ||
1199 | * This method implements the action to be taken when an SCIC_SDS_IO_REQUEST_T | ||
1200 | * object receives a scic_sds_request_frame_handler() request. This method | ||
1201 | * discards the unsolicited frame since we are waiting for the abort task | ||
1202 | * completion. enum sci_status SCI_SUCCESS | ||
1203 | */ | ||
1204 | static enum sci_status scic_sds_request_aborting_state_frame_handler( | ||
1205 | struct scic_sds_request *sci_req, | ||
1206 | u32 frame_index) | ||
1207 | { | ||
1208 | /* TODO: Is it even possible to get an unsolicited frame in the aborting state? */ | ||
1209 | |||
1210 | scic_sds_controller_release_frame( | ||
1211 | sci_req->owning_controller, frame_index); | ||
1212 | |||
1213 | return SCI_SUCCESS; | ||
1214 | } | ||
1215 | |||
1216 | static const struct scic_sds_io_request_state_handler scic_sds_request_state_handler_table[] = { | ||
1217 | [SCI_BASE_REQUEST_STATE_INITIAL] = { | ||
1218 | }, | ||
1219 | [SCI_BASE_REQUEST_STATE_CONSTRUCTED] = { | ||
1220 | .start_handler = scic_sds_request_constructed_state_start_handler, | ||
1221 | .abort_handler = scic_sds_request_constructed_state_abort_handler, | ||
1222 | }, | ||
1223 | [SCI_BASE_REQUEST_STATE_STARTED] = { | ||
1224 | .abort_handler = scic_sds_request_started_state_abort_handler, | ||
1225 | .tc_completion_handler = scic_sds_request_started_state_tc_completion_handler, | ||
1226 | .frame_handler = scic_sds_request_started_state_frame_handler, | ||
1227 | }, | ||
1228 | [SCI_BASE_REQUEST_STATE_COMPLETED] = { | ||
1229 | .complete_handler = scic_sds_request_completed_state_complete_handler, | ||
1230 | }, | ||
1231 | [SCI_BASE_REQUEST_STATE_ABORTING] = { | ||
1232 | .abort_handler = scic_sds_request_aborting_state_abort_handler, | ||
1233 | .tc_completion_handler = scic_sds_request_aborting_state_tc_completion_handler, | ||
1234 | .frame_handler = scic_sds_request_aborting_state_frame_handler, | ||
1235 | }, | ||
1236 | [SCI_BASE_REQUEST_STATE_FINAL] = { | ||
1237 | }, | ||
1238 | }; | ||
1239 | |||
1240 | /** | ||
1241 | * scic_sds_request_initial_state_enter() - | ||
1242 | * @object: This parameter specifies the base object for which the state | ||
1243 | * transition is occurring. | ||
1244 | * | ||
1245 | * This method implements the actions taken when entering the | ||
1246 | * SCI_BASE_REQUEST_STATE_INITIAL state. This state is entered when the initial | ||
1247 | * base request is constructed. Entry into the initial state sets all handlers | ||
1248 | * for the io request object to their default handlers. none | ||
1249 | */ | ||
1250 | static void scic_sds_request_initial_state_enter(void *object) | ||
1251 | { | ||
1252 | struct scic_sds_request *sci_req = object; | ||
1253 | |||
1254 | SET_STATE_HANDLER( | ||
1255 | sci_req, | ||
1256 | scic_sds_request_state_handler_table, | ||
1257 | SCI_BASE_REQUEST_STATE_INITIAL | ||
1258 | ); | ||
1259 | } | ||
1260 | |||
1261 | /** | ||
1262 | * scic_sds_request_constructed_state_enter() - | ||
1263 | * @object: The io request object that is to enter the constructed state. | ||
1264 | * | ||
1265 | * This method implements the actions taken when entering the | ||
1266 | * SCI_BASE_REQUEST_STATE_CONSTRUCTED state. The method sets the state handlers | ||
1267 | * for the the constructed state. none | ||
1268 | */ | ||
1269 | static void scic_sds_request_constructed_state_enter(void *object) | ||
1270 | { | ||
1271 | struct scic_sds_request *sci_req = object; | ||
1272 | |||
1273 | SET_STATE_HANDLER( | ||
1274 | sci_req, | ||
1275 | scic_sds_request_state_handler_table, | ||
1276 | SCI_BASE_REQUEST_STATE_CONSTRUCTED | ||
1277 | ); | ||
1278 | } | ||
1279 | |||
1280 | /** | ||
1281 | * scic_sds_request_started_state_enter() - | ||
1282 | * @object: This parameter specifies the base object for which the state | ||
1283 | * transition is occurring. This is cast into a SCIC_SDS_IO_REQUEST object. | ||
1284 | * | ||
1285 | * This method implements the actions taken when entering the | ||
1286 | * SCI_BASE_REQUEST_STATE_STARTED state. If the io request object type is a | ||
1287 | * SCSI Task request we must enter the started substate machine. none | ||
1288 | */ | ||
1289 | static void scic_sds_request_started_state_enter(void *object) | ||
1290 | { | ||
1291 | struct scic_sds_request *sci_req = object; | ||
1292 | |||
1293 | SET_STATE_HANDLER( | ||
1294 | sci_req, | ||
1295 | scic_sds_request_state_handler_table, | ||
1296 | SCI_BASE_REQUEST_STATE_STARTED | ||
1297 | ); | ||
1298 | |||
1299 | /* | ||
1300 | * Most of the request state machines have a started substate machine so | ||
1301 | * start its execution on the entry to the started state. */ | ||
1302 | if (sci_req->has_started_substate_machine == true) | ||
1303 | sci_base_state_machine_start(&sci_req->started_substate_machine); | ||
1304 | } | ||
1305 | |||
1306 | /** | ||
1307 | * scic_sds_request_started_state_exit() - | ||
1308 | * @object: This parameter specifies the base object for which the state | ||
1309 | * transition is occurring. This object is cast into a SCIC_SDS_IO_REQUEST | ||
1310 | * object. | ||
1311 | * | ||
1312 | * This method implements the actions taken when exiting the | ||
1313 | * SCI_BASE_REQUEST_STATE_STARTED state. For task requests the action will be | ||
1314 | * to stop the started substate machine. none | ||
1315 | */ | ||
1316 | static void scic_sds_request_started_state_exit(void *object) | ||
1317 | { | ||
1318 | struct scic_sds_request *sci_req = object; | ||
1319 | |||
1320 | if (sci_req->has_started_substate_machine == true) | ||
1321 | sci_base_state_machine_stop(&sci_req->started_substate_machine); | ||
1322 | } | ||
1323 | |||
1324 | /** | ||
1325 | * scic_sds_request_completed_state_enter() - | ||
1326 | * @object: This parameter specifies the base object for which the state | ||
1327 | * transition is occurring. This object is cast into a SCIC_SDS_IO_REQUEST | ||
1328 | * object. | ||
1329 | * | ||
1330 | * This method implements the actions taken when entering the | ||
1331 | * SCI_BASE_REQUEST_STATE_COMPLETED state. This state is entered when the | ||
1332 | * SCIC_SDS_IO_REQUEST has completed. The method will decode the request | ||
1333 | * completion status and convert it to an enum sci_status to return in the | ||
1334 | * completion callback function. none | ||
1335 | */ | ||
1336 | static void scic_sds_request_completed_state_enter(void *object) | ||
1337 | { | ||
1338 | struct scic_sds_request *sci_req = object; | ||
1339 | struct scic_sds_controller *scic = | ||
1340 | scic_sds_request_get_controller(sci_req); | ||
1341 | struct isci_host *ihost = scic_to_ihost(scic); | ||
1342 | struct isci_request *ireq = sci_req_to_ireq(sci_req); | ||
1343 | |||
1344 | SET_STATE_HANDLER(sci_req, | ||
1345 | scic_sds_request_state_handler_table, | ||
1346 | SCI_BASE_REQUEST_STATE_COMPLETED); | ||
1347 | |||
1348 | /* Tell the SCI_USER that the IO request is complete */ | ||
1349 | if (sci_req->is_task_management_request == false) | ||
1350 | isci_request_io_request_complete(ihost, | ||
1351 | ireq, | ||
1352 | sci_req->sci_status); | ||
1353 | else | ||
1354 | isci_task_request_complete(ihost, ireq, sci_req->sci_status); | ||
1355 | } | ||
1356 | |||
1357 | /** | ||
1358 | * scic_sds_request_aborting_state_enter() - | ||
1359 | * @object: This parameter specifies the base object for which the state | ||
1360 | * transition is occurring. This object is cast into a SCIC_SDS_IO_REQUEST | ||
1361 | * object. | ||
1362 | * | ||
1363 | * This method implements the actions taken when entering the | ||
1364 | * SCI_BASE_REQUEST_STATE_ABORTING state. none | ||
1365 | */ | ||
1366 | static void scic_sds_request_aborting_state_enter(void *object) | ||
1367 | { | ||
1368 | struct scic_sds_request *sci_req = object; | ||
1369 | |||
1370 | /* Setting the abort bit in the Task Context is required by the silicon. */ | ||
1371 | sci_req->task_context_buffer->abort = 1; | ||
1372 | |||
1373 | SET_STATE_HANDLER( | ||
1374 | sci_req, | ||
1375 | scic_sds_request_state_handler_table, | ||
1376 | SCI_BASE_REQUEST_STATE_ABORTING | ||
1377 | ); | ||
1378 | } | ||
1379 | |||
1380 | /** | ||
1381 | * scic_sds_request_final_state_enter() - | ||
1382 | * @object: This parameter specifies the base object for which the state | ||
1383 | * transition is occurring. This is cast into a SCIC_SDS_IO_REQUEST object. | ||
1384 | * | ||
1385 | * This method implements the actions taken when entering the | ||
1386 | * SCI_BASE_REQUEST_STATE_FINAL state. The only action required is to put the | ||
1387 | * state handlers in place. none | ||
1388 | */ | ||
1389 | static void scic_sds_request_final_state_enter(void *object) | ||
1390 | { | ||
1391 | struct scic_sds_request *sci_req = object; | ||
1392 | |||
1393 | SET_STATE_HANDLER( | ||
1394 | sci_req, | ||
1395 | scic_sds_request_state_handler_table, | ||
1396 | SCI_BASE_REQUEST_STATE_FINAL | ||
1397 | ); | ||
1398 | } | ||
1399 | |||
1400 | static const struct sci_base_state scic_sds_request_state_table[] = { | ||
1401 | [SCI_BASE_REQUEST_STATE_INITIAL] = { | ||
1402 | .enter_state = scic_sds_request_initial_state_enter, | ||
1403 | }, | ||
1404 | [SCI_BASE_REQUEST_STATE_CONSTRUCTED] = { | ||
1405 | .enter_state = scic_sds_request_constructed_state_enter, | ||
1406 | }, | ||
1407 | [SCI_BASE_REQUEST_STATE_STARTED] = { | ||
1408 | .enter_state = scic_sds_request_started_state_enter, | ||
1409 | .exit_state = scic_sds_request_started_state_exit | ||
1410 | }, | ||
1411 | [SCI_BASE_REQUEST_STATE_COMPLETED] = { | ||
1412 | .enter_state = scic_sds_request_completed_state_enter, | ||
1413 | }, | ||
1414 | [SCI_BASE_REQUEST_STATE_ABORTING] = { | ||
1415 | .enter_state = scic_sds_request_aborting_state_enter, | ||
1416 | }, | ||
1417 | [SCI_BASE_REQUEST_STATE_FINAL] = { | ||
1418 | .enter_state = scic_sds_request_final_state_enter, | ||
1419 | }, | ||
1420 | }; | ||
1421 | |||
1422 | static void scic_sds_general_request_construct(struct scic_sds_controller *scic, | ||
1423 | struct scic_sds_remote_device *sci_dev, | ||
1424 | u16 io_tag, struct scic_sds_request *sci_req) | ||
1425 | { | ||
1426 | sci_base_state_machine_construct(&sci_req->state_machine, sci_req, | ||
1427 | scic_sds_request_state_table, SCI_BASE_REQUEST_STATE_INITIAL); | ||
1428 | sci_base_state_machine_start(&sci_req->state_machine); | ||
1429 | |||
1430 | sci_req->io_tag = io_tag; | ||
1431 | sci_req->owning_controller = scic; | ||
1432 | sci_req->target_device = sci_dev; | ||
1433 | sci_req->has_started_substate_machine = false; | ||
1434 | sci_req->protocol = SCIC_NO_PROTOCOL; | ||
1435 | sci_req->saved_rx_frame_index = SCU_INVALID_FRAME_INDEX; | ||
1436 | sci_req->device_sequence = scic_sds_remote_device_get_sequence(sci_dev); | ||
1437 | |||
1438 | sci_req->sci_status = SCI_SUCCESS; | ||
1439 | sci_req->scu_status = 0; | ||
1440 | sci_req->post_context = 0xFFFFFFFF; | ||
1441 | |||
1442 | sci_req->is_task_management_request = false; | ||
1443 | |||
1444 | if (io_tag == SCI_CONTROLLER_INVALID_IO_TAG) { | ||
1445 | sci_req->was_tag_assigned_by_user = false; | ||
1446 | sci_req->task_context_buffer = NULL; | ||
1447 | } else { | ||
1448 | sci_req->was_tag_assigned_by_user = true; | ||
1449 | |||
1450 | sci_req->task_context_buffer = | ||
1451 | scic_sds_controller_get_task_context_buffer(scic, io_tag); | ||
1452 | } | ||
1453 | } | ||
1454 | |||
1455 | enum sci_status | ||
1456 | scic_io_request_construct(struct scic_sds_controller *scic, | ||
1457 | struct scic_sds_remote_device *sci_dev, | ||
1458 | u16 io_tag, struct scic_sds_request *sci_req) | ||
1459 | { | ||
1460 | struct domain_device *dev = sci_dev_to_domain(sci_dev); | ||
1461 | enum sci_status status = SCI_SUCCESS; | ||
1462 | |||
1463 | /* Build the common part of the request */ | ||
1464 | scic_sds_general_request_construct(scic, sci_dev, io_tag, sci_req); | ||
1465 | |||
1466 | if (sci_dev->rnc.remote_node_index == | ||
1467 | SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX) | ||
1468 | return SCI_FAILURE_INVALID_REMOTE_DEVICE; | ||
1469 | |||
1470 | if (dev->dev_type == SAS_END_DEV) | ||
1471 | scic_sds_ssp_io_request_assign_buffers(sci_req); | ||
1472 | else if ((dev->dev_type == SATA_DEV) || | ||
1473 | (dev->tproto & SAS_PROTOCOL_STP)) { | ||
1474 | scic_sds_stp_request_assign_buffers(sci_req); | ||
1475 | memset(&sci_req->stp.cmd, 0, sizeof(sci_req->stp.cmd)); | ||
1476 | } else if (dev_is_expander(dev)) { | ||
1477 | scic_sds_smp_request_assign_buffers(sci_req); | ||
1478 | memset(&sci_req->smp.cmd, 0, sizeof(sci_req->smp.cmd)); | ||
1479 | } else | ||
1480 | status = SCI_FAILURE_UNSUPPORTED_PROTOCOL; | ||
1481 | |||
1482 | if (status == SCI_SUCCESS) { | ||
1483 | memset(sci_req->task_context_buffer, 0, | ||
1484 | offsetof(struct scu_task_context, sgl_pair_ab)); | ||
1485 | } | ||
1486 | |||
1487 | return status; | ||
1488 | } | ||
1489 | |||
1490 | enum sci_status scic_task_request_construct(struct scic_sds_controller *scic, | ||
1491 | struct scic_sds_remote_device *sci_dev, | ||
1492 | u16 io_tag, struct scic_sds_request *sci_req) | ||
1493 | { | ||
1494 | struct domain_device *dev = sci_dev_to_domain(sci_dev); | ||
1495 | enum sci_status status = SCI_SUCCESS; | ||
1496 | |||
1497 | /* Build the common part of the request */ | ||
1498 | scic_sds_general_request_construct(scic, sci_dev, io_tag, sci_req); | ||
1499 | |||
1500 | if (dev->dev_type == SAS_END_DEV) { | ||
1501 | scic_sds_ssp_task_request_assign_buffers(sci_req); | ||
1502 | |||
1503 | sci_req->has_started_substate_machine = true; | ||
1504 | |||
1505 | /* Construct the started sub-state machine. */ | ||
1506 | sci_base_state_machine_construct( | ||
1507 | &sci_req->started_substate_machine, | ||
1508 | sci_req, | ||
1509 | scic_sds_io_request_started_task_mgmt_substate_table, | ||
1510 | SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION | ||
1511 | ); | ||
1512 | } else if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) | ||
1513 | scic_sds_stp_request_assign_buffers(sci_req); | ||
1514 | else | ||
1515 | status = SCI_FAILURE_UNSUPPORTED_PROTOCOL; | ||
1516 | |||
1517 | if (status == SCI_SUCCESS) { | ||
1518 | sci_req->is_task_management_request = true; | ||
1519 | memset(sci_req->task_context_buffer, 0, sizeof(struct scu_task_context)); | ||
1520 | } | ||
1521 | |||
1522 | return status; | ||
1523 | } | ||
diff --git a/drivers/scsi/isci/core/scic_sds_request.h b/drivers/scsi/isci/core/scic_sds_request.h deleted file mode 100644 index a8d74a15a86b..000000000000 --- a/drivers/scsi/isci/core/scic_sds_request.h +++ /dev/null | |||
@@ -1,491 +0,0 @@ | |||
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 | |||
56 | #ifndef _SCIC_SDS_IO_REQUEST_H_ | ||
57 | #define _SCIC_SDS_IO_REQUEST_H_ | ||
58 | |||
59 | #include "isci.h" | ||
60 | #include "scic_io_request.h" | ||
61 | #include "state_machine.h" | ||
62 | #include "scu_task_context.h" | ||
63 | #include "scic_sds_stp_request.h" | ||
64 | #include "sas.h" | ||
65 | |||
66 | struct scic_sds_controller; | ||
67 | struct scic_sds_remote_device; | ||
68 | struct scic_sds_io_request_state_handler; | ||
69 | |||
70 | /** | ||
71 | * enum _scic_sds_io_request_started_task_mgmt_substates - This enumeration | ||
72 | * depicts all of the substates for a task management request to be | ||
73 | * performed in the STARTED super-state. | ||
74 | * | ||
75 | * | ||
76 | */ | ||
77 | enum scic_sds_raw_request_started_task_mgmt_substates { | ||
78 | /** | ||
79 | * The AWAIT_TC_COMPLETION sub-state indicates that the started raw | ||
80 | * task management request is waiting for the transmission of the | ||
81 | * initial frame (i.e. command, task, etc.). | ||
82 | */ | ||
83 | SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION, | ||
84 | |||
85 | /** | ||
86 | * This sub-state indicates that the started task management request | ||
87 | * is waiting for the reception of an unsolicited frame | ||
88 | * (i.e. response IU). | ||
89 | */ | ||
90 | SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE, | ||
91 | }; | ||
92 | |||
93 | |||
94 | /** | ||
95 | * enum _scic_sds_smp_request_started_substates - This enumeration depicts all | ||
96 | * of the substates for a SMP request to be performed in the STARTED | ||
97 | * super-state. | ||
98 | * | ||
99 | * | ||
100 | */ | ||
101 | enum scic_sds_smp_request_started_substates { | ||
102 | /** | ||
103 | * This sub-state indicates that the started task management request | ||
104 | * is waiting for the reception of an unsolicited frame | ||
105 | * (i.e. response IU). | ||
106 | */ | ||
107 | SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_RESPONSE, | ||
108 | |||
109 | /** | ||
110 | * The AWAIT_TC_COMPLETION sub-state indicates that the started SMP request is | ||
111 | * waiting for the transmission of the initial frame (i.e. command, task, etc.). | ||
112 | */ | ||
113 | SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_TC_COMPLETION, | ||
114 | }; | ||
115 | |||
116 | struct scic_sds_request { | ||
117 | /** | ||
118 | * This field contains the information for the base request state machine. | ||
119 | */ | ||
120 | struct sci_base_state_machine state_machine; | ||
121 | |||
122 | /** | ||
123 | * This field simply points to the controller to which this IO request | ||
124 | * is associated. | ||
125 | */ | ||
126 | struct scic_sds_controller *owning_controller; | ||
127 | |||
128 | /** | ||
129 | * This field simply points to the remote device to which this IO request | ||
130 | * is associated. | ||
131 | */ | ||
132 | struct scic_sds_remote_device *target_device; | ||
133 | |||
134 | /** | ||
135 | * This field is utilized to determine if the SCI user is managing | ||
136 | * the IO tag for this request or if the core is managing it. | ||
137 | */ | ||
138 | bool was_tag_assigned_by_user; | ||
139 | |||
140 | /** | ||
141 | * This field indicates the IO tag for this request. The IO tag is | ||
142 | * comprised of the task_index and a sequence count. The sequence count | ||
143 | * is utilized to help identify tasks from one life to another. | ||
144 | */ | ||
145 | u16 io_tag; | ||
146 | |||
147 | /** | ||
148 | * This field specifies the protocol being utilized for this | ||
149 | * IO request. | ||
150 | */ | ||
151 | SCIC_TRANSPORT_PROTOCOL protocol; | ||
152 | |||
153 | /** | ||
154 | * This field indicates the completion status taken from the SCUs | ||
155 | * completion code. It indicates the completion result for the SCU hardware. | ||
156 | */ | ||
157 | u32 scu_status; | ||
158 | |||
159 | /** | ||
160 | * This field indicates the completion status returned to the SCI user. It | ||
161 | * indicates the users view of the io request completion. | ||
162 | */ | ||
163 | u32 sci_status; | ||
164 | |||
165 | /** | ||
166 | * This field contains the value to be utilized when posting (e.g. Post_TC, | ||
167 | * Post_TC_Abort) this request to the silicon. | ||
168 | */ | ||
169 | u32 post_context; | ||
170 | |||
171 | struct scu_task_context *task_context_buffer; | ||
172 | struct scu_task_context tc ____cacheline_aligned; | ||
173 | |||
174 | /* could be larger with sg chaining */ | ||
175 | #define SCU_SGL_SIZE ((SCU_IO_REQUEST_SGE_COUNT + 1) / 2) | ||
176 | struct scu_sgl_element_pair sg_table[SCU_SGL_SIZE] __attribute__ ((aligned(32))); | ||
177 | |||
178 | /** | ||
179 | * This field indicates if this request is a task management request or | ||
180 | * normal IO request. | ||
181 | */ | ||
182 | bool is_task_management_request; | ||
183 | |||
184 | /** | ||
185 | * This field indicates that this request contains an initialized started | ||
186 | * substate machine. | ||
187 | */ | ||
188 | bool has_started_substate_machine; | ||
189 | |||
190 | /** | ||
191 | * This field is a pointer to the stored rx frame data. It is used in STP | ||
192 | * internal requests and SMP response frames. If this field is non-NULL the | ||
193 | * saved frame must be released on IO request completion. | ||
194 | * | ||
195 | * @todo In the future do we want to keep a list of RX frame buffers? | ||
196 | */ | ||
197 | u32 saved_rx_frame_index; | ||
198 | |||
199 | /** | ||
200 | * This field specifies the data necessary to manage the sub-state | ||
201 | * machine executed while in the SCI_BASE_REQUEST_STATE_STARTED state. | ||
202 | */ | ||
203 | struct sci_base_state_machine started_substate_machine; | ||
204 | |||
205 | /** | ||
206 | * This field specifies the current state handlers in place for this | ||
207 | * IO Request object. This field is updated each time the request | ||
208 | * changes state. | ||
209 | */ | ||
210 | const struct scic_sds_io_request_state_handler *state_handlers; | ||
211 | |||
212 | /** | ||
213 | * This field in the recorded device sequence for the io request. This is | ||
214 | * recorded during the build operation and is compared in the start | ||
215 | * operation. If the sequence is different then there was a change of | ||
216 | * devices from the build to start operations. | ||
217 | */ | ||
218 | u8 device_sequence; | ||
219 | |||
220 | union { | ||
221 | struct { | ||
222 | union { | ||
223 | struct ssp_cmd_iu cmd; | ||
224 | struct ssp_task_iu tmf; | ||
225 | }; | ||
226 | union { | ||
227 | struct ssp_response_iu rsp; | ||
228 | u8 rsp_buf[SSP_RESP_IU_MAX_SIZE]; | ||
229 | }; | ||
230 | } ssp; | ||
231 | |||
232 | struct { | ||
233 | struct smp_req cmd; | ||
234 | struct smp_resp rsp; | ||
235 | } smp; | ||
236 | |||
237 | struct { | ||
238 | struct scic_sds_stp_request req; | ||
239 | struct host_to_dev_fis cmd; | ||
240 | struct dev_to_host_fis rsp; | ||
241 | } stp; | ||
242 | }; | ||
243 | |||
244 | }; | ||
245 | |||
246 | static inline struct scic_sds_request *to_sci_req(struct scic_sds_stp_request *stp_req) | ||
247 | { | ||
248 | struct scic_sds_request *sci_req; | ||
249 | |||
250 | sci_req = container_of(stp_req, typeof(*sci_req), stp.req); | ||
251 | return sci_req; | ||
252 | } | ||
253 | |||
254 | /** | ||
255 | * enum sci_base_request_states - This enumeration depicts all the states for | ||
256 | * the common request state machine. | ||
257 | * | ||
258 | * | ||
259 | */ | ||
260 | enum sci_base_request_states { | ||
261 | /** | ||
262 | * Simply the initial state for the base request state machine. | ||
263 | */ | ||
264 | SCI_BASE_REQUEST_STATE_INITIAL, | ||
265 | |||
266 | /** | ||
267 | * This state indicates that the request has been constructed. This state | ||
268 | * is entered from the INITIAL state. | ||
269 | */ | ||
270 | SCI_BASE_REQUEST_STATE_CONSTRUCTED, | ||
271 | |||
272 | /** | ||
273 | * This state indicates that the request has been started. This state is | ||
274 | * entered from the CONSTRUCTED state. | ||
275 | */ | ||
276 | SCI_BASE_REQUEST_STATE_STARTED, | ||
277 | |||
278 | /** | ||
279 | * This state indicates that the request has completed. | ||
280 | * This state is entered from the STARTED state. This state is entered from | ||
281 | * the ABORTING state. | ||
282 | */ | ||
283 | SCI_BASE_REQUEST_STATE_COMPLETED, | ||
284 | |||
285 | /** | ||
286 | * This state indicates that the request is in the process of being | ||
287 | * terminated/aborted. | ||
288 | * This state is entered from the CONSTRUCTED state. | ||
289 | * This state is entered from the STARTED state. | ||
290 | */ | ||
291 | SCI_BASE_REQUEST_STATE_ABORTING, | ||
292 | |||
293 | /** | ||
294 | * Simply the final state for the base request state machine. | ||
295 | */ | ||
296 | SCI_BASE_REQUEST_STATE_FINAL, | ||
297 | }; | ||
298 | |||
299 | typedef enum sci_status (*scic_sds_io_request_handler_t) | ||
300 | (struct scic_sds_request *request); | ||
301 | typedef enum sci_status (*scic_sds_io_request_frame_handler_t) | ||
302 | (struct scic_sds_request *req, u32 frame); | ||
303 | typedef enum sci_status (*scic_sds_io_request_event_handler_t) | ||
304 | (struct scic_sds_request *req, u32 event); | ||
305 | typedef enum sci_status (*scic_sds_io_request_task_completion_handler_t) | ||
306 | (struct scic_sds_request *req, u32 completion_code); | ||
307 | |||
308 | /** | ||
309 | * struct scic_sds_io_request_state_handler - This is the SDS core definition | ||
310 | * of the state handlers. | ||
311 | * | ||
312 | * | ||
313 | */ | ||
314 | struct scic_sds_io_request_state_handler { | ||
315 | /** | ||
316 | * The start_handler specifies the method invoked when a user attempts to | ||
317 | * start a request. | ||
318 | */ | ||
319 | scic_sds_io_request_handler_t start_handler; | ||
320 | |||
321 | /** | ||
322 | * The abort_handler specifies the method invoked when a user attempts to | ||
323 | * abort a request. | ||
324 | */ | ||
325 | scic_sds_io_request_handler_t abort_handler; | ||
326 | |||
327 | /** | ||
328 | * The complete_handler specifies the method invoked when a user attempts to | ||
329 | * complete a request. | ||
330 | */ | ||
331 | scic_sds_io_request_handler_t complete_handler; | ||
332 | |||
333 | scic_sds_io_request_task_completion_handler_t tc_completion_handler; | ||
334 | scic_sds_io_request_event_handler_t event_handler; | ||
335 | scic_sds_io_request_frame_handler_t frame_handler; | ||
336 | |||
337 | }; | ||
338 | |||
339 | extern const struct sci_base_state scic_sds_io_request_started_task_mgmt_substate_table[]; | ||
340 | |||
341 | /** | ||
342 | * scic_sds_request_get_controller() - | ||
343 | * | ||
344 | * This macro will return the controller for this io request object | ||
345 | */ | ||
346 | #define scic_sds_request_get_controller(sci_req) \ | ||
347 | ((sci_req)->owning_controller) | ||
348 | |||
349 | /** | ||
350 | * scic_sds_request_get_device() - | ||
351 | * | ||
352 | * This macro will return the device for this io request object | ||
353 | */ | ||
354 | #define scic_sds_request_get_device(sci_req) \ | ||
355 | ((sci_req)->target_device) | ||
356 | |||
357 | /** | ||
358 | * scic_sds_request_get_port() - | ||
359 | * | ||
360 | * This macro will return the port for this io request object | ||
361 | */ | ||
362 | #define scic_sds_request_get_port(sci_req) \ | ||
363 | scic_sds_remote_device_get_port(scic_sds_request_get_device(sci_req)) | ||
364 | |||
365 | /** | ||
366 | * scic_sds_request_get_post_context() - | ||
367 | * | ||
368 | * This macro returns the constructed post context result for the io request. | ||
369 | */ | ||
370 | #define scic_sds_request_get_post_context(sci_req) \ | ||
371 | ((sci_req)->post_context) | ||
372 | |||
373 | /** | ||
374 | * scic_sds_request_get_task_context() - | ||
375 | * | ||
376 | * This is a helper macro to return the os handle for this request object. | ||
377 | */ | ||
378 | #define scic_sds_request_get_task_context(request) \ | ||
379 | ((request)->task_context_buffer) | ||
380 | |||
381 | /** | ||
382 | * scic_sds_request_set_status() - | ||
383 | * | ||
384 | * This macro will set the scu hardware status and sci request completion | ||
385 | * status for an io request. | ||
386 | */ | ||
387 | #define scic_sds_request_set_status(request, scu_status_code, sci_status_code) \ | ||
388 | { \ | ||
389 | (request)->scu_status = (scu_status_code); \ | ||
390 | (request)->sci_status = (sci_status_code); \ | ||
391 | } | ||
392 | |||
393 | #define scic_sds_request_complete(a_request) \ | ||
394 | ((a_request)->state_handlers->complete_handler(a_request)) | ||
395 | |||
396 | |||
397 | extern enum sci_status | ||
398 | scic_sds_io_request_tc_completion(struct scic_sds_request *request, u32 completion_code); | ||
399 | |||
400 | /** | ||
401 | * SCU_SGL_ZERO() - | ||
402 | * | ||
403 | * This macro zeros the hardware SGL element data | ||
404 | */ | ||
405 | #define SCU_SGL_ZERO(scu_sge) \ | ||
406 | { \ | ||
407 | (scu_sge).length = 0; \ | ||
408 | (scu_sge).address_lower = 0; \ | ||
409 | (scu_sge).address_upper = 0; \ | ||
410 | (scu_sge).address_modifier = 0; \ | ||
411 | } | ||
412 | |||
413 | /** | ||
414 | * SCU_SGL_COPY() - | ||
415 | * | ||
416 | * This macro copys the SGL Element data from the host os to the hardware SGL | ||
417 | * elment data | ||
418 | */ | ||
419 | #define SCU_SGL_COPY(scu_sge, os_sge) \ | ||
420 | { \ | ||
421 | (scu_sge).length = sg_dma_len(sg); \ | ||
422 | (scu_sge).address_upper = \ | ||
423 | upper_32_bits(sg_dma_address(sg)); \ | ||
424 | (scu_sge).address_lower = \ | ||
425 | lower_32_bits(sg_dma_address(sg)); \ | ||
426 | (scu_sge).address_modifier = 0; \ | ||
427 | } | ||
428 | |||
429 | /** | ||
430 | * scic_sds_request_get_user_request() - | ||
431 | * | ||
432 | * This is a helper macro to return the os handle for this request object. | ||
433 | */ | ||
434 | #define scic_sds_request_get_user_request(request) \ | ||
435 | ((request)->user_request) | ||
436 | |||
437 | /* | ||
438 | * ***************************************************************************** | ||
439 | * * CORE REQUEST PROTOTYPES | ||
440 | * ***************************************************************************** */ | ||
441 | |||
442 | void scic_sds_request_build_sgl( | ||
443 | struct scic_sds_request *sci_req); | ||
444 | |||
445 | |||
446 | |||
447 | void scic_sds_stp_request_assign_buffers( | ||
448 | struct scic_sds_request *sci_req); | ||
449 | |||
450 | void scic_sds_smp_request_assign_buffers( | ||
451 | struct scic_sds_request *sci_req); | ||
452 | |||
453 | /* --------------------------------------------------------------------------- */ | ||
454 | |||
455 | enum sci_status scic_sds_request_start( | ||
456 | struct scic_sds_request *sci_req); | ||
457 | |||
458 | enum sci_status scic_sds_io_request_terminate( | ||
459 | struct scic_sds_request *sci_req); | ||
460 | |||
461 | enum sci_status scic_sds_io_request_complete( | ||
462 | struct scic_sds_request *sci_req); | ||
463 | |||
464 | void scic_sds_io_request_copy_response( | ||
465 | struct scic_sds_request *sci_req); | ||
466 | |||
467 | enum sci_status scic_sds_io_request_event_handler( | ||
468 | struct scic_sds_request *sci_req, | ||
469 | u32 event_code); | ||
470 | |||
471 | enum sci_status scic_sds_io_request_frame_handler( | ||
472 | struct scic_sds_request *sci_req, | ||
473 | u32 frame_index); | ||
474 | |||
475 | |||
476 | enum sci_status scic_sds_task_request_terminate( | ||
477 | struct scic_sds_request *sci_req); | ||
478 | |||
479 | /* | ||
480 | * ***************************************************************************** | ||
481 | * * STARTED STATE HANDLERS | ||
482 | * ***************************************************************************** */ | ||
483 | |||
484 | enum sci_status scic_sds_request_started_state_abort_handler( | ||
485 | struct scic_sds_request *sci_req); | ||
486 | |||
487 | enum sci_status scic_sds_request_started_state_tc_completion_handler( | ||
488 | struct scic_sds_request *sci_req, | ||
489 | u32 completion_code); | ||
490 | |||
491 | #endif /* _SCIC_SDS_IO_REQUEST_H_ */ | ||
diff --git a/drivers/scsi/isci/core/scic_sds_smp_request.h b/drivers/scsi/isci/core/scic_sds_smp_request.h deleted file mode 100644 index f432b7a182cd..000000000000 --- a/drivers/scsi/isci/core/scic_sds_smp_request.h +++ /dev/null | |||
@@ -1,67 +0,0 @@ | |||
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 | #ifndef _SCIC_SDS_SMP_REQUEST_T_ | ||
56 | #define _SCIC_SDS_SMP_REQUEST_T_ | ||
57 | |||
58 | #include "scic_sds_request.h" | ||
59 | |||
60 | |||
61 | u32 scic_sds_smp_request_get_object_size(void); | ||
62 | |||
63 | |||
64 | void scic_sds_smp_request_copy_response(struct scic_sds_request *sci_req); | ||
65 | |||
66 | #endif /* _SCIC_SDS_SMP_REQUEST_T_ */ | ||
67 | |||
diff --git a/drivers/scsi/isci/core/scic_sds_stp_packet_request.h b/drivers/scsi/isci/core/scic_sds_stp_packet_request.h deleted file mode 100644 index e94d689e5103..000000000000 --- a/drivers/scsi/isci/core/scic_sds_stp_packet_request.h +++ /dev/null | |||
@@ -1,113 +0,0 @@ | |||
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 | #ifndef _SCIC_SDS_STP_PACKET_REQUEST_H_ | ||
56 | #define _SCIC_SDS_STP_PACKET_REQUEST_H_ | ||
57 | |||
58 | #include "scic_sds_stp_request.h" | ||
59 | |||
60 | /** | ||
61 | * This file contains the structures and constants for PACKET protocol requests. | ||
62 | * | ||
63 | * | ||
64 | */ | ||
65 | |||
66 | |||
67 | /** | ||
68 | * | ||
69 | * | ||
70 | * This is the enumeration of the SATA PIO DATA IN started substate machine. | ||
71 | */ | ||
72 | enum _scic_sds_stp_packet_request_started_substates { | ||
73 | /** | ||
74 | * While in this state the IO request object is waiting for the TC completion | ||
75 | * notification for the H2D Register FIS | ||
76 | */ | ||
77 | SCIC_SDS_STP_PACKET_REQUEST_STARTED_PACKET_PHASE_AWAIT_TC_COMPLETION_SUBSTATE, | ||
78 | |||
79 | /** | ||
80 | * While in this state the IO request object is waiting for either a PIO Setup. | ||
81 | */ | ||
82 | SCIC_SDS_STP_PACKET_REQUEST_STARTED_PACKET_PHASE_AWAIT_PIO_SETUP_SUBSTATE, | ||
83 | |||
84 | /** | ||
85 | * While in this state the IO request object is waiting for TC completion for | ||
86 | * the Packet DMA DATA fis or Raw Frame. | ||
87 | */ | ||
88 | SCIC_SDS_STP_PACKET_REQUEST_STARTED_COMMAND_PHASE_AWAIT_TC_COMPLETION_SUBSTATE, | ||
89 | |||
90 | /** | ||
91 | * The non-data IO transit to this state in this state after receiving TC | ||
92 | * completion. While in this state IO request object is waiting for D2H status | ||
93 | * frame as UF. | ||
94 | */ | ||
95 | SCIC_SDS_STP_PACKET_REQUEST_STARTED_COMMAND_PHASE_AWAIT_D2H_FIS_SUBSTATE, | ||
96 | |||
97 | /** | ||
98 | * The IO transit to this state in this state if the previous TC completion status | ||
99 | * is not success and the atapi device is suspended due to target device failed the IO. | ||
100 | * While in this state IO request object is waiting for device coming out of the | ||
101 | * suspension state then complete the IO. | ||
102 | */ | ||
103 | SCIC_SDS_STP_PACKET_REQUEST_STARTED_COMPLETION_DELAY_SUBSTATE, | ||
104 | }; | ||
105 | |||
106 | #define scic_sds_stp_packet_request_construct(request) SCI_FAILURE | ||
107 | #define scu_stp_packet_request_command_phase_construct_task_context(reqeust, tc) | ||
108 | #define scu_stp_packet_request_command_phase_reconstruct_raw_frame_task_context(reqeust, tc) | ||
109 | #define scic_sds_stp_packet_request_process_status_fis(reqeust, fis) SCI_FAILURE | ||
110 | #define scic_sds_stp_packet_internal_request_sense_build_sgl(request) | ||
111 | |||
112 | #endif /* _SCIC_SDS_STP_PACKET_REQUEST_H_ */ | ||
113 | |||
diff --git a/drivers/scsi/isci/core/scic_sds_stp_pio_request.h b/drivers/scsi/isci/core/scic_sds_stp_pio_request.h deleted file mode 100644 index e015a1114760..000000000000 --- a/drivers/scsi/isci/core/scic_sds_stp_pio_request.h +++ /dev/null | |||
@@ -1,104 +0,0 @@ | |||
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 | |||
56 | #ifndef _SCIC_SDS_SATA_PIO_REQUEST_H_ | ||
57 | #define _SCIC_SDS_SATA_PIO_REQUEST_H_ | ||
58 | |||
59 | #include "scic_sds_request.h" | ||
60 | #include "scu_task_context.h" | ||
61 | |||
62 | /** | ||
63 | * This file contains the structures and constants for SATA PIO requests. | ||
64 | * | ||
65 | * | ||
66 | */ | ||
67 | |||
68 | |||
69 | /** | ||
70 | * | ||
71 | * | ||
72 | * This is the enumeration of the SATA PIO DATA IN started substate machine. | ||
73 | */ | ||
74 | enum _scic_sds_stp_request_started_pio_substates { | ||
75 | /** | ||
76 | * While in this state the IO request object is waiting for the TC completion | ||
77 | * notification for the H2D Register FIS | ||
78 | */ | ||
79 | SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_H2D_COMPLETION_SUBSTATE, | ||
80 | |||
81 | /** | ||
82 | * While in this state the IO request object is waiting for either a PIO Setup | ||
83 | * FIS or a D2H register FIS. The type of frame received is based on the | ||
84 | * result of the prior frame and line conditions. | ||
85 | */ | ||
86 | SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_FRAME_SUBSTATE, | ||
87 | |||
88 | /** | ||
89 | * While in this state the IO request object is waiting for a DATA frame from | ||
90 | * the device. | ||
91 | */ | ||
92 | SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_IN_AWAIT_DATA_SUBSTATE, | ||
93 | |||
94 | /** | ||
95 | * While in this state the IO request object is waiting to transmit the next data | ||
96 | * frame to the device. | ||
97 | */ | ||
98 | SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_OUT_TRANSMIT_DATA_SUBSTATE, | ||
99 | }; | ||
100 | |||
101 | struct scic_sds_stp_request; | ||
102 | |||
103 | |||
104 | #endif /* _SCIC_SDS_SATA_PIO_REQUEST_H_ */ | ||
diff --git a/drivers/scsi/isci/core/scic_task_request.h b/drivers/scsi/isci/core/scic_task_request.h deleted file mode 100644 index 790cee9b4af6..000000000000 --- a/drivers/scsi/isci/core/scic_task_request.h +++ /dev/null | |||
@@ -1,104 +0,0 @@ | |||
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 | |||
56 | #ifndef _SCIC_TASK_REQUEST_H_ | ||
57 | #define _SCIC_TASK_REQUEST_H_ | ||
58 | |||
59 | #include "isci.h" | ||
60 | |||
61 | struct scic_sds_request; | ||
62 | struct scic_sds_remote_device; | ||
63 | struct scic_sds_controller; | ||
64 | |||
65 | |||
66 | enum sci_status scic_task_request_construct( | ||
67 | struct scic_sds_controller *scic_controller, | ||
68 | struct scic_sds_remote_device *scic_remote_device, | ||
69 | u16 io_tag, struct scic_sds_request *sci_req); | ||
70 | |||
71 | /** | ||
72 | * scic_task_request_construct_ssp() - This method is called by the SCI user to | ||
73 | * construct all SCI Core SSP task management requests. Memory | ||
74 | * initialization and functionality common to all task request types is | ||
75 | * performed in this method. | ||
76 | * @scic_task_request: This parameter specifies the handle to the core task | ||
77 | * request object for which to construct a SATA specific task management | ||
78 | * request. | ||
79 | * | ||
80 | * Indicate if the controller successfully built the task request. SCI_SUCCESS | ||
81 | * This value is returned if the task request was successfully built. | ||
82 | */ | ||
83 | enum sci_status scic_task_request_construct_ssp( | ||
84 | struct scic_sds_request *scic_task_request); | ||
85 | |||
86 | /** | ||
87 | * scic_task_request_construct_sata() - This method is called by the SCI user | ||
88 | * to construct all SCI Core SATA task management requests. Memory | ||
89 | * initialization and functionality common to all task request types is | ||
90 | * performed in this method. | ||
91 | * @scic_task_request_handle: This parameter specifies the handle to the core | ||
92 | * task request object for which to construct a SATA specific task | ||
93 | * management request. | ||
94 | * | ||
95 | * Indicate if the controller successfully built the task request. SCI_SUCCESS | ||
96 | * This value is returned if the task request was successfully built. | ||
97 | */ | ||
98 | enum sci_status scic_task_request_construct_sata( | ||
99 | struct scic_sds_request *scic_task_request_handle); | ||
100 | |||
101 | |||
102 | |||
103 | #endif /* _SCIC_TASK_REQUEST_H_ */ | ||
104 | |||
diff --git a/drivers/scsi/isci/host.c b/drivers/scsi/isci/host.c index 71a0466d1c8e..e1930da08d4e 100644 --- a/drivers/scsi/isci/host.c +++ b/drivers/scsi/isci/host.c | |||
@@ -61,9 +61,7 @@ | |||
61 | #include "probe_roms.h" | 61 | #include "probe_roms.h" |
62 | #include "remote_device.h" | 62 | #include "remote_device.h" |
63 | #include "request.h" | 63 | #include "request.h" |
64 | #include "scic_io_request.h" | ||
65 | #include "scic_sds_port_configuration_agent.h" | 64 | #include "scic_sds_port_configuration_agent.h" |
66 | #include "sci_util.h" | ||
67 | #include "scu_completion_codes.h" | 65 | #include "scu_completion_codes.h" |
68 | #include "scu_event_codes.h" | 66 | #include "scu_event_codes.h" |
69 | #include "registers.h" | 67 | #include "registers.h" |
diff --git a/drivers/scsi/isci/isci.h b/drivers/scsi/isci/isci.h index d288897b85fb..69826eac97b5 100644 --- a/drivers/scsi/isci/isci.h +++ b/drivers/scsi/isci/isci.h | |||
@@ -521,6 +521,25 @@ enum sci_task_status { | |||
521 | 521 | ||
522 | }; | 522 | }; |
523 | 523 | ||
524 | /** | ||
525 | * sci_swab32_cpy - convert between scsi and scu-hardware byte format | ||
526 | * @dest: receive the 4-byte endian swapped version of src | ||
527 | * @src: word aligned source buffer | ||
528 | * | ||
529 | * scu hardware handles SSP/SMP control, response, and unidentified | ||
530 | * frames in "big endian dword" order. Regardless of host endian this | ||
531 | * is always a swab32()-per-dword conversion of the standard definition, | ||
532 | * i.e. single byte fields swapped and multi-byte fields in little- | ||
533 | * endian | ||
534 | */ | ||
535 | static inline void sci_swab32_cpy(void *_dest, void *_src, ssize_t word_cnt) | ||
536 | { | ||
537 | u32 *dest = _dest, *src = _src; | ||
538 | |||
539 | while (--word_cnt >= 0) | ||
540 | dest[word_cnt] = swab32(src[word_cnt]); | ||
541 | } | ||
542 | |||
524 | extern unsigned char no_outbound_task_to; | 543 | extern unsigned char no_outbound_task_to; |
525 | extern u16 ssp_max_occ_to; | 544 | extern u16 ssp_max_occ_to; |
526 | extern u16 stp_max_occ_to; | 545 | extern u16 stp_max_occ_to; |
diff --git a/drivers/scsi/isci/port.c b/drivers/scsi/isci/port.c index f44fa20cad96..d4bf6d2d8c9b 100644 --- a/drivers/scsi/isci/port.c +++ b/drivers/scsi/isci/port.c | |||
@@ -55,7 +55,6 @@ | |||
55 | 55 | ||
56 | #include <linux/workqueue.h> | 56 | #include <linux/workqueue.h> |
57 | #include "isci.h" | 57 | #include "isci.h" |
58 | #include "scic_io_request.h" | ||
59 | #include "scic_phy.h" | 58 | #include "scic_phy.h" |
60 | #include "scic_sds_phy.h" | 59 | #include "scic_sds_phy.h" |
61 | #include "scic_port.h" | 60 | #include "scic_port.h" |
diff --git a/drivers/scsi/isci/remote_device.c b/drivers/scsi/isci/remote_device.c index 00334b9ccd80..23390102514f 100644 --- a/drivers/scsi/isci/remote_device.c +++ b/drivers/scsi/isci/remote_device.c | |||
@@ -57,14 +57,11 @@ | |||
57 | #include "port.h" | 57 | #include "port.h" |
58 | #include "remote_device.h" | 58 | #include "remote_device.h" |
59 | #include "request.h" | 59 | #include "request.h" |
60 | #include "scic_io_request.h" | ||
61 | #include "scic_phy.h" | 60 | #include "scic_phy.h" |
62 | #include "scic_port.h" | 61 | #include "scic_port.h" |
63 | #include "scic_sds_phy.h" | 62 | #include "scic_sds_phy.h" |
64 | #include "scic_sds_port.h" | 63 | #include "scic_sds_port.h" |
65 | #include "remote_node_context.h" | 64 | #include "remote_node_context.h" |
66 | #include "scic_sds_request.h" | ||
67 | #include "sci_util.h" | ||
68 | #include "scu_event_codes.h" | 65 | #include "scu_event_codes.h" |
69 | #include "task.h" | 66 | #include "task.h" |
70 | 67 | ||
diff --git a/drivers/scsi/isci/remote_node_context.c b/drivers/scsi/isci/remote_node_context.c index 5891f3d50177..35231e7407b1 100644 --- a/drivers/scsi/isci/remote_node_context.c +++ b/drivers/scsi/isci/remote_node_context.c | |||
@@ -58,7 +58,6 @@ | |||
58 | #include "scic_sds_port.h" | 58 | #include "scic_sds_port.h" |
59 | #include "remote_device.h" | 59 | #include "remote_device.h" |
60 | #include "remote_node_context.h" | 60 | #include "remote_node_context.h" |
61 | #include "sci_util.h" | ||
62 | #include "scu_event_codes.h" | 61 | #include "scu_event_codes.h" |
63 | #include "scu_task_context.h" | 62 | #include "scu_task_context.h" |
64 | 63 | ||
diff --git a/drivers/scsi/isci/remote_node_table.c b/drivers/scsi/isci/remote_node_table.c index 80f44c25f45f..6b9465a5a217 100644 --- a/drivers/scsi/isci/remote_node_table.c +++ b/drivers/scsi/isci/remote_node_table.c | |||
@@ -59,7 +59,6 @@ | |||
59 | * | 59 | * |
60 | * | 60 | * |
61 | */ | 61 | */ |
62 | #include "sci_util.h" | ||
63 | #include "remote_node_table.h" | 62 | #include "remote_node_table.h" |
64 | #include "remote_node_context.h" | 63 | #include "remote_node_context.h" |
65 | 64 | ||
diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c index 4961ee347091..857ad067f11c 100644 --- a/drivers/scsi/isci/request.c +++ b/drivers/scsi/isci/request.c | |||
@@ -54,407 +54,1128 @@ | |||
54 | */ | 54 | */ |
55 | 55 | ||
56 | #include "isci.h" | 56 | #include "isci.h" |
57 | #include "scic_io_request.h" | ||
58 | #include "scic_task_request.h" | ||
59 | #include "scic_port.h" | 57 | #include "scic_port.h" |
60 | #include "task.h" | 58 | #include "task.h" |
61 | #include "request.h" | 59 | #include "request.h" |
62 | #include "sata.h" | 60 | #include "sata.h" |
63 | #include "scu_completion_codes.h" | 61 | #include "scu_completion_codes.h" |
64 | #include "scic_sds_request.h" | ||
65 | #include "sas.h" | 62 | #include "sas.h" |
66 | 63 | ||
67 | static enum sci_status isci_request_ssp_request_construct( | 64 | /** |
68 | struct isci_request *request) | 65 | * This method returns the sgl element pair for the specificed sgl_pair index. |
66 | * @sci_req: This parameter specifies the IO request for which to retrieve | ||
67 | * the Scatter-Gather List element pair. | ||
68 | * @sgl_pair_index: This parameter specifies the index into the SGL element | ||
69 | * pair to be retrieved. | ||
70 | * | ||
71 | * This method returns a pointer to an struct scu_sgl_element_pair. | ||
72 | */ | ||
73 | static struct scu_sgl_element_pair *scic_sds_request_get_sgl_element_pair( | ||
74 | struct scic_sds_request *sci_req, | ||
75 | u32 sgl_pair_index | ||
76 | ) { | ||
77 | struct scu_task_context *task_context; | ||
78 | |||
79 | task_context = (struct scu_task_context *)sci_req->task_context_buffer; | ||
80 | |||
81 | if (sgl_pair_index == 0) { | ||
82 | return &task_context->sgl_pair_ab; | ||
83 | } else if (sgl_pair_index == 1) { | ||
84 | return &task_context->sgl_pair_cd; | ||
85 | } | ||
86 | |||
87 | return &sci_req->sg_table[sgl_pair_index - 2]; | ||
88 | } | ||
89 | |||
90 | /** | ||
91 | * This function will build the SGL list for an IO request. | ||
92 | * @sci_req: This parameter specifies the IO request for which to build | ||
93 | * the Scatter-Gather List. | ||
94 | * | ||
95 | */ | ||
96 | void scic_sds_request_build_sgl(struct scic_sds_request *sds_request) | ||
69 | { | 97 | { |
70 | enum sci_status status; | 98 | struct isci_request *isci_request = sci_req_to_ireq(sds_request); |
99 | struct isci_host *isci_host = isci_request->isci_host; | ||
100 | struct sas_task *task = isci_request_access_task(isci_request); | ||
101 | struct scatterlist *sg = NULL; | ||
102 | dma_addr_t dma_addr; | ||
103 | u32 sg_idx = 0; | ||
104 | struct scu_sgl_element_pair *scu_sg = NULL; | ||
105 | struct scu_sgl_element_pair *prev_sg = NULL; | ||
106 | |||
107 | if (task->num_scatter > 0) { | ||
108 | sg = task->scatter; | ||
109 | |||
110 | while (sg) { | ||
111 | scu_sg = scic_sds_request_get_sgl_element_pair( | ||
112 | sds_request, | ||
113 | sg_idx); | ||
114 | |||
115 | SCU_SGL_COPY(scu_sg->A, sg); | ||
116 | |||
117 | sg = sg_next(sg); | ||
118 | |||
119 | if (sg) { | ||
120 | SCU_SGL_COPY(scu_sg->B, sg); | ||
121 | sg = sg_next(sg); | ||
122 | } else | ||
123 | SCU_SGL_ZERO(scu_sg->B); | ||
124 | |||
125 | if (prev_sg) { | ||
126 | dma_addr = | ||
127 | scic_io_request_get_dma_addr( | ||
128 | sds_request, | ||
129 | scu_sg); | ||
130 | |||
131 | prev_sg->next_pair_upper = | ||
132 | upper_32_bits(dma_addr); | ||
133 | prev_sg->next_pair_lower = | ||
134 | lower_32_bits(dma_addr); | ||
135 | } | ||
136 | |||
137 | prev_sg = scu_sg; | ||
138 | sg_idx++; | ||
139 | } | ||
140 | } else { /* handle when no sg */ | ||
141 | scu_sg = scic_sds_request_get_sgl_element_pair(sds_request, | ||
142 | sg_idx); | ||
71 | 143 | ||
72 | dev_dbg(&request->isci_host->pdev->dev, | 144 | dma_addr = dma_map_single(&isci_host->pdev->dev, |
73 | "%s: request = %p\n", | 145 | task->scatter, |
74 | __func__, | 146 | task->total_xfer_len, |
75 | request); | 147 | task->data_dir); |
76 | status = scic_io_request_construct_basic_ssp(&request->sci); | 148 | |
77 | return status; | 149 | isci_request->zero_scatter_daddr = dma_addr; |
150 | |||
151 | scu_sg->A.length = task->total_xfer_len; | ||
152 | scu_sg->A.address_upper = upper_32_bits(dma_addr); | ||
153 | scu_sg->A.address_lower = lower_32_bits(dma_addr); | ||
154 | } | ||
155 | |||
156 | if (scu_sg) { | ||
157 | scu_sg->next_pair_upper = 0; | ||
158 | scu_sg->next_pair_lower = 0; | ||
159 | } | ||
78 | } | 160 | } |
79 | 161 | ||
80 | static enum sci_status isci_request_stp_request_construct( | 162 | static void scic_sds_ssp_io_request_assign_buffers(struct scic_sds_request *sci_req) |
81 | struct isci_request *request) | ||
82 | { | 163 | { |
83 | struct sas_task *task = isci_request_access_task(request); | 164 | if (sci_req->was_tag_assigned_by_user == false) |
84 | enum sci_status status; | 165 | sci_req->task_context_buffer = &sci_req->tc; |
85 | struct host_to_dev_fis *register_fis; | 166 | } |
86 | 167 | ||
87 | dev_dbg(&request->isci_host->pdev->dev, | 168 | static void scic_sds_io_request_build_ssp_command_iu(struct scic_sds_request *sci_req) |
88 | "%s: request = %p\n", | 169 | { |
89 | __func__, | 170 | struct ssp_cmd_iu *cmd_iu; |
90 | request); | 171 | struct isci_request *ireq = sci_req_to_ireq(sci_req); |
172 | struct sas_task *task = isci_request_access_task(ireq); | ||
91 | 173 | ||
92 | /* Get the host_to_dev_fis from the core and copy | 174 | cmd_iu = &sci_req->ssp.cmd; |
93 | * the fis from the task into it. | ||
94 | */ | ||
95 | register_fis = isci_sata_task_to_fis_copy(task); | ||
96 | 175 | ||
97 | status = scic_io_request_construct_basic_sata(&request->sci); | 176 | memcpy(cmd_iu->LUN, task->ssp_task.LUN, 8); |
177 | cmd_iu->add_cdb_len = 0; | ||
178 | cmd_iu->_r_a = 0; | ||
179 | cmd_iu->_r_b = 0; | ||
180 | cmd_iu->en_fburst = 0; /* unsupported */ | ||
181 | cmd_iu->task_prio = task->ssp_task.task_prio; | ||
182 | cmd_iu->task_attr = task->ssp_task.task_attr; | ||
183 | cmd_iu->_r_c = 0; | ||
98 | 184 | ||
99 | /* Set the ncq tag in the fis, from the queue | 185 | sci_swab32_cpy(&cmd_iu->cdb, task->ssp_task.cdb, |
100 | * command in the task. | 186 | sizeof(task->ssp_task.cdb) / sizeof(u32)); |
101 | */ | 187 | } |
102 | if (isci_sata_is_task_ncq(task)) { | ||
103 | 188 | ||
104 | isci_sata_set_ncq_tag( | 189 | static void scic_sds_task_request_build_ssp_task_iu(struct scic_sds_request *sci_req) |
105 | register_fis, | 190 | { |
106 | task | 191 | struct ssp_task_iu *task_iu; |
107 | ); | 192 | struct isci_request *ireq = sci_req_to_ireq(sci_req); |
193 | struct sas_task *task = isci_request_access_task(ireq); | ||
194 | struct isci_tmf *isci_tmf = isci_request_access_tmf(ireq); | ||
195 | |||
196 | task_iu = &sci_req->ssp.tmf; | ||
197 | |||
198 | memset(task_iu, 0, sizeof(struct ssp_task_iu)); | ||
199 | |||
200 | memcpy(task_iu->LUN, task->ssp_task.LUN, 8); | ||
201 | |||
202 | task_iu->task_func = isci_tmf->tmf_code; | ||
203 | task_iu->task_tag = | ||
204 | (ireq->ttype == tmf_task) ? | ||
205 | isci_tmf->io_tag : | ||
206 | SCI_CONTROLLER_INVALID_IO_TAG; | ||
207 | } | ||
208 | |||
209 | /** | ||
210 | * This method is will fill in the SCU Task Context for any type of SSP request. | ||
211 | * @sci_req: | ||
212 | * @task_context: | ||
213 | * | ||
214 | */ | ||
215 | static void scu_ssp_reqeust_construct_task_context( | ||
216 | struct scic_sds_request *sds_request, | ||
217 | struct scu_task_context *task_context) | ||
218 | { | ||
219 | dma_addr_t dma_addr; | ||
220 | struct scic_sds_controller *controller; | ||
221 | struct scic_sds_remote_device *target_device; | ||
222 | struct scic_sds_port *target_port; | ||
223 | |||
224 | controller = scic_sds_request_get_controller(sds_request); | ||
225 | target_device = scic_sds_request_get_device(sds_request); | ||
226 | target_port = scic_sds_request_get_port(sds_request); | ||
227 | |||
228 | /* Fill in the TC with the its required data */ | ||
229 | task_context->abort = 0; | ||
230 | task_context->priority = 0; | ||
231 | task_context->initiator_request = 1; | ||
232 | task_context->connection_rate = target_device->connection_rate; | ||
233 | task_context->protocol_engine_index = | ||
234 | scic_sds_controller_get_protocol_engine_group(controller); | ||
235 | task_context->logical_port_index = | ||
236 | scic_sds_port_get_index(target_port); | ||
237 | task_context->protocol_type = SCU_TASK_CONTEXT_PROTOCOL_SSP; | ||
238 | task_context->valid = SCU_TASK_CONTEXT_VALID; | ||
239 | task_context->context_type = SCU_TASK_CONTEXT_TYPE; | ||
240 | |||
241 | task_context->remote_node_index = | ||
242 | scic_sds_remote_device_get_index(sds_request->target_device); | ||
243 | task_context->command_code = 0; | ||
244 | |||
245 | task_context->link_layer_control = 0; | ||
246 | task_context->do_not_dma_ssp_good_response = 1; | ||
247 | task_context->strict_ordering = 0; | ||
248 | task_context->control_frame = 0; | ||
249 | task_context->timeout_enable = 0; | ||
250 | task_context->block_guard_enable = 0; | ||
251 | |||
252 | task_context->address_modifier = 0; | ||
253 | |||
254 | /* task_context->type.ssp.tag = sci_req->io_tag; */ | ||
255 | task_context->task_phase = 0x01; | ||
256 | |||
257 | if (sds_request->was_tag_assigned_by_user) { | ||
258 | /* | ||
259 | * Build the task context now since we have already read | ||
260 | * the data | ||
261 | */ | ||
262 | sds_request->post_context = | ||
263 | (SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC | | ||
264 | (scic_sds_controller_get_protocol_engine_group( | ||
265 | controller) << | ||
266 | SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT) | | ||
267 | (scic_sds_port_get_index(target_port) << | ||
268 | SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT) | | ||
269 | scic_sds_io_tag_get_index(sds_request->io_tag)); | ||
270 | } else { | ||
271 | /* | ||
272 | * Build the task context now since we have already read | ||
273 | * the data | ||
274 | * | ||
275 | * I/O tag index is not assigned because we have to wait | ||
276 | * until we get a TCi | ||
277 | */ | ||
278 | sds_request->post_context = | ||
279 | (SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC | | ||
280 | (scic_sds_controller_get_protocol_engine_group( | ||
281 | owning_controller) << | ||
282 | SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT) | | ||
283 | (scic_sds_port_get_index(target_port) << | ||
284 | SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT)); | ||
108 | } | 285 | } |
109 | 286 | ||
110 | return status; | 287 | /* |
288 | * Copy the physical address for the command buffer to the | ||
289 | * SCU Task Context | ||
290 | */ | ||
291 | dma_addr = scic_io_request_get_dma_addr(sds_request, | ||
292 | &sds_request->ssp.cmd); | ||
293 | |||
294 | task_context->command_iu_upper = upper_32_bits(dma_addr); | ||
295 | task_context->command_iu_lower = lower_32_bits(dma_addr); | ||
296 | |||
297 | /* | ||
298 | * Copy the physical address for the response buffer to the | ||
299 | * SCU Task Context | ||
300 | */ | ||
301 | dma_addr = scic_io_request_get_dma_addr(sds_request, | ||
302 | &sds_request->ssp.rsp); | ||
303 | |||
304 | task_context->response_iu_upper = upper_32_bits(dma_addr); | ||
305 | task_context->response_iu_lower = lower_32_bits(dma_addr); | ||
111 | } | 306 | } |
112 | 307 | ||
113 | /* | 308 | /** |
114 | * isci_smp_request_build() - This function builds the smp request. | 309 | * This method is will fill in the SCU Task Context for a SSP IO request. |
115 | * @ireq: This parameter points to the isci_request allocated in the | 310 | * @sci_req: |
116 | * request construct function. | ||
117 | * | 311 | * |
118 | * SCI_SUCCESS on successfull completion, or specific failure code. | ||
119 | */ | 312 | */ |
120 | static enum sci_status isci_smp_request_build(struct isci_request *ireq) | 313 | static void scu_ssp_io_request_construct_task_context( |
314 | struct scic_sds_request *sci_req, | ||
315 | enum dma_data_direction dir, | ||
316 | u32 len) | ||
121 | { | 317 | { |
122 | enum sci_status status = SCI_FAILURE; | 318 | struct scu_task_context *task_context; |
123 | struct sas_task *task = isci_request_access_task(ireq); | ||
124 | struct scic_sds_request *sci_req = &ireq->sci; | ||
125 | 319 | ||
126 | dev_dbg(&ireq->isci_host->pdev->dev, | 320 | task_context = scic_sds_request_get_task_context(sci_req); |
127 | "%s: request = %p\n", __func__, ireq); | ||
128 | 321 | ||
129 | dev_dbg(&ireq->isci_host->pdev->dev, | 322 | scu_ssp_reqeust_construct_task_context(sci_req, task_context); |
130 | "%s: smp_req len = %d\n", | ||
131 | __func__, | ||
132 | task->smp_task.smp_req.length); | ||
133 | 323 | ||
134 | /* copy the smp_command to the address; */ | 324 | task_context->ssp_command_iu_length = |
135 | sg_copy_to_buffer(&task->smp_task.smp_req, 1, | 325 | sizeof(struct ssp_cmd_iu) / sizeof(u32); |
136 | &sci_req->smp.cmd, | 326 | task_context->type.ssp.frame_type = SSP_COMMAND; |
137 | sizeof(struct smp_req)); | ||
138 | 327 | ||
139 | status = scic_io_request_construct_smp(sci_req); | 328 | switch (dir) { |
140 | if (status != SCI_SUCCESS) | 329 | case DMA_FROM_DEVICE: |
141 | dev_warn(&ireq->isci_host->pdev->dev, | 330 | case DMA_NONE: |
142 | "%s: failed with status = %d\n", | 331 | default: |
143 | __func__, | 332 | task_context->task_type = SCU_TASK_TYPE_IOREAD; |
144 | status); | 333 | break; |
334 | case DMA_TO_DEVICE: | ||
335 | task_context->task_type = SCU_TASK_TYPE_IOWRITE; | ||
336 | break; | ||
337 | } | ||
145 | 338 | ||
146 | return status; | 339 | task_context->transfer_length_bytes = len; |
340 | |||
341 | if (task_context->transfer_length_bytes > 0) | ||
342 | scic_sds_request_build_sgl(sci_req); | ||
343 | } | ||
344 | |||
345 | static void scic_sds_ssp_task_request_assign_buffers(struct scic_sds_request *sci_req) | ||
346 | { | ||
347 | if (sci_req->was_tag_assigned_by_user == false) | ||
348 | sci_req->task_context_buffer = &sci_req->tc; | ||
147 | } | 349 | } |
148 | 350 | ||
149 | /** | 351 | /** |
150 | * isci_io_request_build() - This function builds the io request object. | 352 | * This method will fill in the SCU Task Context for a SSP Task request. The |
151 | * @isci_host: This parameter specifies the ISCI host object | 353 | * following important settings are utilized: -# priority == |
152 | * @request: This parameter points to the isci_request object allocated in the | 354 | * SCU_TASK_PRIORITY_HIGH. This ensures that the task request is issued |
153 | * request construct function. | 355 | * ahead of other task destined for the same Remote Node. -# task_type == |
154 | * @sci_device: This parameter is the handle for the sci core's remote device | 356 | * SCU_TASK_TYPE_IOREAD. This simply indicates that a normal request type |
155 | * object that is the destination for this request. | 357 | * (i.e. non-raw frame) is being utilized to perform task management. -# |
358 | * control_frame == 1. This ensures that the proper endianess is set so | ||
359 | * that the bytes are transmitted in the right order for a task frame. | ||
360 | * @sci_req: This parameter specifies the task request object being | ||
361 | * constructed. | ||
156 | * | 362 | * |
157 | * SCI_SUCCESS on successfull completion, or specific failure code. | ||
158 | */ | 363 | */ |
159 | static enum sci_status isci_io_request_build( | 364 | static void scu_ssp_task_request_construct_task_context( |
160 | struct isci_host *isci_host, | 365 | struct scic_sds_request *sci_req) |
161 | struct isci_request *request, | ||
162 | struct isci_remote_device *isci_device) | ||
163 | { | 366 | { |
164 | enum sci_status status = SCI_SUCCESS; | 367 | struct scu_task_context *task_context; |
165 | struct sas_task *task = isci_request_access_task(request); | ||
166 | struct scic_sds_remote_device *sci_device = &isci_device->sci; | ||
167 | 368 | ||
168 | dev_dbg(&isci_host->pdev->dev, | 369 | task_context = scic_sds_request_get_task_context(sci_req); |
169 | "%s: isci_device = 0x%p; request = %p, " | ||
170 | "num_scatter = %d\n", | ||
171 | __func__, | ||
172 | isci_device, | ||
173 | request, | ||
174 | task->num_scatter); | ||
175 | 370 | ||
176 | /* map the sgl addresses, if present. | 371 | scu_ssp_reqeust_construct_task_context(sci_req, task_context); |
177 | * libata does the mapping for sata devices | ||
178 | * before we get the request. | ||
179 | */ | ||
180 | if (task->num_scatter && | ||
181 | !sas_protocol_ata(task->task_proto) && | ||
182 | !(SAS_PROTOCOL_SMP & task->task_proto)) { | ||
183 | 372 | ||
184 | request->num_sg_entries = dma_map_sg( | 373 | task_context->control_frame = 1; |
185 | &isci_host->pdev->dev, | 374 | task_context->priority = SCU_TASK_PRIORITY_HIGH; |
186 | task->scatter, | 375 | task_context->task_type = SCU_TASK_TYPE_RAW_FRAME; |
187 | task->num_scatter, | 376 | task_context->transfer_length_bytes = 0; |
188 | task->data_dir | 377 | task_context->type.ssp.frame_type = SSP_TASK; |
189 | ); | 378 | task_context->ssp_command_iu_length = |
379 | sizeof(struct ssp_task_iu) / sizeof(u32); | ||
380 | } | ||
190 | 381 | ||
191 | if (request->num_sg_entries == 0) | ||
192 | return SCI_FAILURE_INSUFFICIENT_RESOURCES; | ||
193 | } | ||
194 | 382 | ||
195 | /* build the common request object. For now, | 383 | /** |
196 | * we will let the core allocate the IO tag. | 384 | * This method constructs the SSP Command IU data for this ssp passthrough |
197 | */ | 385 | * comand request object. |
198 | status = scic_io_request_construct(&isci_host->sci, sci_device, | 386 | * @sci_req: This parameter specifies the request object for which the SSP |
199 | SCI_CONTROLLER_INVALID_IO_TAG, | 387 | * command information unit is being built. |
200 | &request->sci); | 388 | * |
389 | * enum sci_status, returns invalid parameter is cdb > 16 | ||
390 | */ | ||
201 | 391 | ||
202 | if (status != SCI_SUCCESS) { | 392 | |
203 | dev_warn(&isci_host->pdev->dev, | 393 | /** |
204 | "%s: failed request construct\n", | 394 | * This method constructs the SATA request object. |
205 | __func__); | 395 | * @sci_req: |
206 | return SCI_FAILURE; | 396 | * @sat_protocol: |
397 | * @transfer_length: | ||
398 | * @data_direction: | ||
399 | * @copy_rx_frame: | ||
400 | * | ||
401 | * enum sci_status | ||
402 | */ | ||
403 | static enum sci_status | ||
404 | scic_io_request_construct_sata(struct scic_sds_request *sci_req, | ||
405 | u32 len, | ||
406 | enum dma_data_direction dir, | ||
407 | bool copy) | ||
408 | { | ||
409 | enum sci_status status = SCI_SUCCESS; | ||
410 | struct isci_request *ireq = sci_req_to_ireq(sci_req); | ||
411 | struct sas_task *task = isci_request_access_task(ireq); | ||
412 | |||
413 | /* check for management protocols */ | ||
414 | if (ireq->ttype == tmf_task) { | ||
415 | struct isci_tmf *tmf = isci_request_access_tmf(ireq); | ||
416 | |||
417 | if (tmf->tmf_code == isci_tmf_sata_srst_high || | ||
418 | tmf->tmf_code == isci_tmf_sata_srst_low) | ||
419 | return scic_sds_stp_soft_reset_request_construct(sci_req); | ||
420 | else { | ||
421 | dev_err(scic_to_dev(sci_req->owning_controller), | ||
422 | "%s: Request 0x%p received un-handled SAT " | ||
423 | "management protocol 0x%x.\n", | ||
424 | __func__, sci_req, tmf->tmf_code); | ||
425 | |||
426 | return SCI_FAILURE; | ||
427 | } | ||
207 | } | 428 | } |
208 | 429 | ||
209 | switch (task->task_proto) { | 430 | if (!sas_protocol_ata(task->task_proto)) { |
210 | case SAS_PROTOCOL_SMP: | 431 | dev_err(scic_to_dev(sci_req->owning_controller), |
211 | status = isci_smp_request_build(request); | 432 | "%s: Non-ATA protocol in SATA path: 0x%x\n", |
212 | break; | 433 | __func__, |
213 | case SAS_PROTOCOL_SSP: | 434 | task->task_proto); |
214 | status = isci_request_ssp_request_construct(request); | ||
215 | break; | ||
216 | case SAS_PROTOCOL_SATA: | ||
217 | case SAS_PROTOCOL_STP: | ||
218 | case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP: | ||
219 | status = isci_request_stp_request_construct(request); | ||
220 | break; | ||
221 | default: | ||
222 | dev_warn(&isci_host->pdev->dev, | ||
223 | "%s: unknown protocol\n", __func__); | ||
224 | return SCI_FAILURE; | 435 | return SCI_FAILURE; |
436 | |||
225 | } | 437 | } |
226 | 438 | ||
439 | /* non data */ | ||
440 | if (task->data_dir == DMA_NONE) | ||
441 | return scic_sds_stp_non_data_request_construct(sci_req); | ||
442 | |||
443 | /* NCQ */ | ||
444 | if (task->ata_task.use_ncq) | ||
445 | return scic_sds_stp_ncq_request_construct(sci_req, len, dir); | ||
446 | |||
447 | /* DMA */ | ||
448 | if (task->ata_task.dma_xfer) | ||
449 | return scic_sds_stp_udma_request_construct(sci_req, len, dir); | ||
450 | else /* PIO */ | ||
451 | return scic_sds_stp_pio_request_construct(sci_req, copy); | ||
452 | |||
453 | return status; | ||
454 | } | ||
455 | |||
456 | static enum sci_status scic_io_request_construct_basic_ssp(struct scic_sds_request *sci_req) | ||
457 | { | ||
458 | struct isci_request *ireq = sci_req_to_ireq(sci_req); | ||
459 | struct sas_task *task = isci_request_access_task(ireq); | ||
460 | |||
461 | sci_req->protocol = SCIC_SSP_PROTOCOL; | ||
462 | |||
463 | scu_ssp_io_request_construct_task_context(sci_req, | ||
464 | task->data_dir, | ||
465 | task->total_xfer_len); | ||
466 | |||
467 | scic_sds_io_request_build_ssp_command_iu(sci_req); | ||
468 | |||
469 | sci_base_state_machine_change_state( | ||
470 | &sci_req->state_machine, | ||
471 | SCI_BASE_REQUEST_STATE_CONSTRUCTED); | ||
472 | |||
473 | return SCI_SUCCESS; | ||
474 | } | ||
475 | |||
476 | enum sci_status scic_task_request_construct_ssp( | ||
477 | struct scic_sds_request *sci_req) | ||
478 | { | ||
479 | /* Construct the SSP Task SCU Task Context */ | ||
480 | scu_ssp_task_request_construct_task_context(sci_req); | ||
481 | |||
482 | /* Fill in the SSP Task IU */ | ||
483 | scic_sds_task_request_build_ssp_task_iu(sci_req); | ||
484 | |||
485 | sci_base_state_machine_change_state(&sci_req->state_machine, | ||
486 | SCI_BASE_REQUEST_STATE_CONSTRUCTED); | ||
487 | |||
227 | return SCI_SUCCESS; | 488 | return SCI_SUCCESS; |
228 | } | 489 | } |
229 | 490 | ||
230 | 491 | ||
492 | static enum sci_status scic_io_request_construct_basic_sata(struct scic_sds_request *sci_req) | ||
493 | { | ||
494 | enum sci_status status; | ||
495 | struct scic_sds_stp_request *stp_req; | ||
496 | bool copy = false; | ||
497 | struct isci_request *isci_request = sci_req_to_ireq(sci_req); | ||
498 | struct sas_task *task = isci_request_access_task(isci_request); | ||
499 | |||
500 | stp_req = &sci_req->stp.req; | ||
501 | sci_req->protocol = SCIC_STP_PROTOCOL; | ||
502 | |||
503 | copy = (task->data_dir == DMA_NONE) ? false : true; | ||
504 | |||
505 | status = scic_io_request_construct_sata(sci_req, | ||
506 | task->total_xfer_len, | ||
507 | task->data_dir, | ||
508 | copy); | ||
509 | |||
510 | if (status == SCI_SUCCESS) | ||
511 | sci_base_state_machine_change_state(&sci_req->state_machine, | ||
512 | SCI_BASE_REQUEST_STATE_CONSTRUCTED); | ||
513 | |||
514 | return status; | ||
515 | } | ||
516 | |||
517 | |||
518 | enum sci_status scic_task_request_construct_sata(struct scic_sds_request *sci_req) | ||
519 | { | ||
520 | enum sci_status status = SCI_SUCCESS; | ||
521 | struct isci_request *ireq = sci_req_to_ireq(sci_req); | ||
522 | |||
523 | /* check for management protocols */ | ||
524 | if (ireq->ttype == tmf_task) { | ||
525 | struct isci_tmf *tmf = isci_request_access_tmf(ireq); | ||
526 | |||
527 | if (tmf->tmf_code == isci_tmf_sata_srst_high || | ||
528 | tmf->tmf_code == isci_tmf_sata_srst_low) { | ||
529 | status = scic_sds_stp_soft_reset_request_construct(sci_req); | ||
530 | } else { | ||
531 | dev_err(scic_to_dev(sci_req->owning_controller), | ||
532 | "%s: Request 0x%p received un-handled SAT " | ||
533 | "Protocol 0x%x.\n", | ||
534 | __func__, sci_req, tmf->tmf_code); | ||
535 | |||
536 | return SCI_FAILURE; | ||
537 | } | ||
538 | } | ||
539 | |||
540 | if (status == SCI_SUCCESS) | ||
541 | sci_base_state_machine_change_state( | ||
542 | &sci_req->state_machine, | ||
543 | SCI_BASE_REQUEST_STATE_CONSTRUCTED); | ||
544 | |||
545 | return status; | ||
546 | } | ||
547 | |||
231 | /** | 548 | /** |
232 | * isci_request_alloc_core() - This function gets the request object from the | 549 | * sci_req_tx_bytes - bytes transferred when reply underruns request |
233 | * isci_host dma cache. | 550 | * @sci_req: request that was terminated early |
234 | * @isci_host: This parameter specifies the ISCI host object | ||
235 | * @isci_request: This parameter will contain the pointer to the new | ||
236 | * isci_request object. | ||
237 | * @isci_device: This parameter is the pointer to the isci remote device object | ||
238 | * that is the destination for this request. | ||
239 | * @gfp_flags: This parameter specifies the os allocation flags. | ||
240 | * | ||
241 | * SCI_SUCCESS on successfull completion, or specific failure code. | ||
242 | */ | 551 | */ |
243 | static int isci_request_alloc_core( | 552 | #define SCU_TASK_CONTEXT_SRAM 0x200000 |
244 | struct isci_host *isci_host, | 553 | static u32 sci_req_tx_bytes(struct scic_sds_request *sci_req) |
245 | struct isci_request **isci_request, | ||
246 | struct isci_remote_device *isci_device, | ||
247 | gfp_t gfp_flags) | ||
248 | { | 554 | { |
249 | int ret = 0; | 555 | struct scic_sds_controller *scic = sci_req->owning_controller; |
250 | dma_addr_t handle; | 556 | u32 ret_val = 0; |
251 | struct isci_request *request; | ||
252 | 557 | ||
558 | if (readl(&scic->smu_registers->address_modifier) == 0) { | ||
559 | void __iomem *scu_reg_base = scic->scu_registers; | ||
253 | 560 | ||
254 | /* get pointer to dma memory. This actually points | 561 | /* get the bytes of data from the Address == BAR1 + 20002Ch + (256*TCi) where |
255 | * to both the isci_remote_device object and the | 562 | * BAR1 is the scu_registers |
256 | * sci object. The isci object is at the beginning | 563 | * 0x20002C = 0x200000 + 0x2c |
257 | * of the memory allocated here. | 564 | * = start of task context SRAM + offset of (type.ssp.data_offset) |
258 | */ | 565 | * TCi is the io_tag of struct scic_sds_request |
259 | request = dma_pool_alloc(isci_host->dma_pool, gfp_flags, &handle); | 566 | */ |
260 | if (!request) { | 567 | ret_val = readl(scu_reg_base + |
261 | dev_warn(&isci_host->pdev->dev, | 568 | (SCU_TASK_CONTEXT_SRAM + offsetof(struct scu_task_context, type.ssp.data_offset)) + |
262 | "%s: dma_pool_alloc returned NULL\n", __func__); | 569 | ((sizeof(struct scu_task_context)) * scic_sds_io_tag_get_index(sci_req->io_tag))); |
263 | return -ENOMEM; | ||
264 | } | 570 | } |
265 | 571 | ||
266 | /* initialize the request object. */ | 572 | return ret_val; |
267 | spin_lock_init(&request->state_lock); | 573 | } |
268 | request->request_daddr = handle; | ||
269 | request->isci_host = isci_host; | ||
270 | request->isci_device = isci_device; | ||
271 | request->io_request_completion = NULL; | ||
272 | request->terminated = false; | ||
273 | 574 | ||
274 | request->num_sg_entries = 0; | 575 | enum sci_status |
576 | scic_sds_request_start(struct scic_sds_request *request) | ||
577 | { | ||
578 | if (request->device_sequence != | ||
579 | scic_sds_remote_device_get_sequence(request->target_device)) | ||
580 | return SCI_FAILURE; | ||
275 | 581 | ||
276 | request->complete_in_target = false; | 582 | if (request->state_handlers->start_handler) |
583 | return request->state_handlers->start_handler(request); | ||
277 | 584 | ||
278 | INIT_LIST_HEAD(&request->completed_node); | 585 | dev_warn(scic_to_dev(request->owning_controller), |
279 | INIT_LIST_HEAD(&request->dev_node); | 586 | "%s: SCIC IO Request requested to start while in wrong " |
587 | "state %d\n", | ||
588 | __func__, | ||
589 | sci_base_state_machine_get_state(&request->state_machine)); | ||
280 | 590 | ||
281 | *isci_request = request; | 591 | return SCI_FAILURE_INVALID_STATE; |
282 | isci_request_change_state(request, allocated); | 592 | } |
283 | 593 | ||
284 | return ret; | 594 | enum sci_status |
595 | scic_sds_io_request_terminate(struct scic_sds_request *request) | ||
596 | { | ||
597 | if (request->state_handlers->abort_handler) | ||
598 | return request->state_handlers->abort_handler(request); | ||
599 | |||
600 | dev_warn(scic_to_dev(request->owning_controller), | ||
601 | "%s: SCIC IO Request requested to abort while in wrong " | ||
602 | "state %d\n", | ||
603 | __func__, | ||
604 | sci_base_state_machine_get_state(&request->state_machine)); | ||
605 | |||
606 | return SCI_FAILURE_INVALID_STATE; | ||
285 | } | 607 | } |
286 | 608 | ||
287 | static int isci_request_alloc_io( | 609 | enum sci_status scic_sds_io_request_event_handler( |
288 | struct isci_host *isci_host, | 610 | struct scic_sds_request *request, |
289 | struct sas_task *task, | 611 | u32 event_code) |
290 | struct isci_request **isci_request, | ||
291 | struct isci_remote_device *isci_device, | ||
292 | gfp_t gfp_flags) | ||
293 | { | 612 | { |
294 | int retval = isci_request_alloc_core(isci_host, isci_request, | 613 | if (request->state_handlers->event_handler) |
295 | isci_device, gfp_flags); | 614 | return request->state_handlers->event_handler(request, event_code); |
296 | 615 | ||
297 | if (!retval) { | 616 | dev_warn(scic_to_dev(request->owning_controller), |
298 | (*isci_request)->ttype_ptr.io_task_ptr = task; | 617 | "%s: SCIC IO Request given event code notification %x while " |
299 | (*isci_request)->ttype = io_task; | 618 | "in wrong state %d\n", |
619 | __func__, | ||
620 | event_code, | ||
621 | sci_base_state_machine_get_state(&request->state_machine)); | ||
300 | 622 | ||
301 | task->lldd_task = *isci_request; | 623 | return SCI_FAILURE_INVALID_STATE; |
302 | } | ||
303 | return retval; | ||
304 | } | 624 | } |
305 | 625 | ||
306 | /** | 626 | /** |
307 | * isci_request_alloc_tmf() - This function gets the request object from the | ||
308 | * isci_host dma cache and initializes the relevant fields as a sas_task. | ||
309 | * @isci_host: This parameter specifies the ISCI host object | ||
310 | * @sas_task: This parameter is the task struct from the upper layer driver. | ||
311 | * @isci_request: This parameter will contain the pointer to the new | ||
312 | * isci_request object. | ||
313 | * @isci_device: This parameter is the pointer to the isci remote device object | ||
314 | * that is the destination for this request. | ||
315 | * @gfp_flags: This parameter specifies the os allocation flags. | ||
316 | * | 627 | * |
317 | * SCI_SUCCESS on successfull completion, or specific failure code. | 628 | * @sci_req: The SCIC_SDS_IO_REQUEST_T object for which the start |
629 | * operation is to be executed. | ||
630 | * @frame_index: The frame index returned by the hardware for the reqeust | ||
631 | * object. | ||
632 | * | ||
633 | * This method invokes the core state frame handler for the | ||
634 | * SCIC_SDS_IO_REQUEST_T object. enum sci_status | ||
318 | */ | 635 | */ |
319 | int isci_request_alloc_tmf( | 636 | enum sci_status scic_sds_io_request_frame_handler( |
320 | struct isci_host *isci_host, | 637 | struct scic_sds_request *request, |
321 | struct isci_tmf *isci_tmf, | 638 | u32 frame_index) |
322 | struct isci_request **isci_request, | ||
323 | struct isci_remote_device *isci_device, | ||
324 | gfp_t gfp_flags) | ||
325 | { | 639 | { |
326 | int retval = isci_request_alloc_core(isci_host, isci_request, | 640 | if (request->state_handlers->frame_handler) |
327 | isci_device, gfp_flags); | 641 | return request->state_handlers->frame_handler(request, frame_index); |
642 | |||
643 | dev_warn(scic_to_dev(request->owning_controller), | ||
644 | "%s: SCIC IO Request given unexpected frame %x while in " | ||
645 | "state %d\n", | ||
646 | __func__, | ||
647 | frame_index, | ||
648 | sci_base_state_machine_get_state(&request->state_machine)); | ||
649 | |||
650 | scic_sds_controller_release_frame(request->owning_controller, frame_index); | ||
651 | return SCI_FAILURE_INVALID_STATE; | ||
652 | } | ||
328 | 653 | ||
329 | if (!retval) { | 654 | /* |
655 | * This function copies response data for requests returning response data | ||
656 | * instead of sense data. | ||
657 | * @sci_req: This parameter specifies the request object for which to copy | ||
658 | * the response data. | ||
659 | */ | ||
660 | void scic_sds_io_request_copy_response(struct scic_sds_request *sci_req) | ||
661 | { | ||
662 | void *resp_buf; | ||
663 | u32 len; | ||
664 | struct ssp_response_iu *ssp_response; | ||
665 | struct isci_request *ireq = sci_req_to_ireq(sci_req); | ||
666 | struct isci_tmf *isci_tmf = isci_request_access_tmf(ireq); | ||
330 | 667 | ||
331 | (*isci_request)->ttype_ptr.tmf_task_ptr = isci_tmf; | 668 | ssp_response = &sci_req->ssp.rsp; |
332 | (*isci_request)->ttype = tmf_task; | 669 | |
670 | resp_buf = &isci_tmf->resp.resp_iu; | ||
671 | |||
672 | len = min_t(u32, | ||
673 | SSP_RESP_IU_MAX_SIZE, | ||
674 | be32_to_cpu(ssp_response->response_data_len)); | ||
675 | |||
676 | memcpy(resp_buf, ssp_response->resp_data, len); | ||
677 | } | ||
678 | |||
679 | /* | ||
680 | * This method implements the action taken when a constructed | ||
681 | * SCIC_SDS_IO_REQUEST_T object receives a scic_sds_request_start() request. | ||
682 | * This method will, if necessary, allocate a TCi for the io request object and | ||
683 | * then will, if necessary, copy the constructed TC data into the actual TC | ||
684 | * buffer. If everything is successful the post context field is updated with | ||
685 | * the TCi so the controller can post the request to the hardware. enum sci_status | ||
686 | * SCI_SUCCESS SCI_FAILURE_INSUFFICIENT_RESOURCES | ||
687 | */ | ||
688 | static enum sci_status scic_sds_request_constructed_state_start_handler( | ||
689 | struct scic_sds_request *request) | ||
690 | { | ||
691 | struct scu_task_context *task_context; | ||
692 | |||
693 | if (request->io_tag == SCI_CONTROLLER_INVALID_IO_TAG) { | ||
694 | request->io_tag = | ||
695 | scic_controller_allocate_io_tag(request->owning_controller); | ||
333 | } | 696 | } |
334 | return retval; | 697 | |
698 | /* Record the IO Tag in the request */ | ||
699 | if (request->io_tag != SCI_CONTROLLER_INVALID_IO_TAG) { | ||
700 | task_context = request->task_context_buffer; | ||
701 | |||
702 | task_context->task_index = scic_sds_io_tag_get_index(request->io_tag); | ||
703 | |||
704 | switch (task_context->protocol_type) { | ||
705 | case SCU_TASK_CONTEXT_PROTOCOL_SMP: | ||
706 | case SCU_TASK_CONTEXT_PROTOCOL_SSP: | ||
707 | /* SSP/SMP Frame */ | ||
708 | task_context->type.ssp.tag = request->io_tag; | ||
709 | task_context->type.ssp.target_port_transfer_tag = 0xFFFF; | ||
710 | break; | ||
711 | |||
712 | case SCU_TASK_CONTEXT_PROTOCOL_STP: | ||
713 | /* | ||
714 | * STP/SATA Frame | ||
715 | * task_context->type.stp.ncq_tag = request->ncq_tag; */ | ||
716 | break; | ||
717 | |||
718 | case SCU_TASK_CONTEXT_PROTOCOL_NONE: | ||
719 | /* / @todo When do we set no protocol type? */ | ||
720 | break; | ||
721 | |||
722 | default: | ||
723 | /* This should never happen since we build the IO requests */ | ||
724 | break; | ||
725 | } | ||
726 | |||
727 | /* | ||
728 | * Check to see if we need to copy the task context buffer | ||
729 | * or have been building into the task context buffer */ | ||
730 | if (request->was_tag_assigned_by_user == false) { | ||
731 | scic_sds_controller_copy_task_context( | ||
732 | request->owning_controller, request); | ||
733 | } | ||
734 | |||
735 | /* Add to the post_context the io tag value */ | ||
736 | request->post_context |= scic_sds_io_tag_get_index(request->io_tag); | ||
737 | |||
738 | /* Everything is good go ahead and change state */ | ||
739 | sci_base_state_machine_change_state(&request->state_machine, | ||
740 | SCI_BASE_REQUEST_STATE_STARTED); | ||
741 | |||
742 | return SCI_SUCCESS; | ||
743 | } | ||
744 | |||
745 | return SCI_FAILURE_INSUFFICIENT_RESOURCES; | ||
335 | } | 746 | } |
336 | 747 | ||
337 | /** | 748 | /* |
338 | * isci_request_execute() - This function allocates the isci_request object, | 749 | * This method implements the action to be taken when an SCIC_SDS_IO_REQUEST_T |
339 | * all fills in some common fields. | 750 | * object receives a scic_sds_request_terminate() request. Since the request |
340 | * @isci_host: This parameter specifies the ISCI host object | 751 | * has not yet been posted to the hardware the request transitions to the |
341 | * @sas_task: This parameter is the task struct from the upper layer driver. | 752 | * completed state. enum sci_status SCI_SUCCESS |
342 | * @isci_request: This parameter will contain the pointer to the new | 753 | */ |
343 | * isci_request object. | 754 | static enum sci_status scic_sds_request_constructed_state_abort_handler( |
344 | * @gfp_flags: This parameter specifies the os allocation flags. | 755 | struct scic_sds_request *request) |
756 | { | ||
757 | /* | ||
758 | * This request has been terminated by the user make sure that the correct | ||
759 | * status code is returned */ | ||
760 | scic_sds_request_set_status(request, | ||
761 | SCU_TASK_DONE_TASK_ABORT, | ||
762 | SCI_FAILURE_IO_TERMINATED); | ||
763 | |||
764 | sci_base_state_machine_change_state(&request->state_machine, | ||
765 | SCI_BASE_REQUEST_STATE_COMPLETED); | ||
766 | return SCI_SUCCESS; | ||
767 | } | ||
768 | |||
769 | /* | ||
770 | * ***************************************************************************** | ||
771 | * * STARTED STATE HANDLERS | ||
772 | * ***************************************************************************** */ | ||
773 | |||
774 | /* | ||
775 | * This method implements the action to be taken when an SCIC_SDS_IO_REQUEST_T | ||
776 | * object receives a scic_sds_request_terminate() request. Since the request | ||
777 | * has been posted to the hardware the io request state is changed to the | ||
778 | * aborting state. enum sci_status SCI_SUCCESS | ||
779 | */ | ||
780 | enum sci_status scic_sds_request_started_state_abort_handler( | ||
781 | struct scic_sds_request *request) | ||
782 | { | ||
783 | if (request->has_started_substate_machine) | ||
784 | sci_base_state_machine_stop(&request->started_substate_machine); | ||
785 | |||
786 | sci_base_state_machine_change_state(&request->state_machine, | ||
787 | SCI_BASE_REQUEST_STATE_ABORTING); | ||
788 | return SCI_SUCCESS; | ||
789 | } | ||
790 | |||
791 | /* | ||
792 | * scic_sds_request_started_state_tc_completion_handler() - This method process | ||
793 | * TC (task context) completions for normal IO request (i.e. Task/Abort | ||
794 | * Completions of type 0). This method will update the | ||
795 | * SCIC_SDS_IO_REQUEST_T::status field. | ||
796 | * @sci_req: This parameter specifies the request for which a completion | ||
797 | * occurred. | ||
798 | * @completion_code: This parameter specifies the completion code received from | ||
799 | * the SCU. | ||
345 | * | 800 | * |
346 | * SCI_SUCCESS on successfull completion, or specific failure code. | ||
347 | */ | 801 | */ |
348 | int isci_request_execute( | 802 | static enum sci_status |
349 | struct isci_host *isci_host, | 803 | scic_sds_request_started_state_tc_completion_handler(struct scic_sds_request *sci_req, |
350 | struct sas_task *task, | 804 | u32 completion_code) |
351 | struct isci_request **isci_request, | ||
352 | gfp_t gfp_flags) | ||
353 | { | 805 | { |
354 | int ret = 0; | 806 | u8 datapres; |
355 | struct scic_sds_remote_device *sci_device; | 807 | struct ssp_response_iu *resp_iu; |
356 | enum sci_status status = SCI_FAILURE_UNSUPPORTED_PROTOCOL; | ||
357 | struct isci_remote_device *isci_device; | ||
358 | struct isci_request *request; | ||
359 | unsigned long flags; | ||
360 | 808 | ||
361 | isci_device = task->dev->lldd_dev; | 809 | /* |
362 | sci_device = &isci_device->sci; | 810 | * TODO: Any SDMA return code of other than 0 is bad |
811 | * decode 0x003C0000 to determine SDMA status | ||
812 | */ | ||
813 | switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) { | ||
814 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD): | ||
815 | scic_sds_request_set_status(sci_req, | ||
816 | SCU_TASK_DONE_GOOD, | ||
817 | SCI_SUCCESS); | ||
818 | break; | ||
363 | 819 | ||
364 | /* do common allocation and init of request object. */ | 820 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_EARLY_RESP): |
365 | ret = isci_request_alloc_io( | 821 | { |
366 | isci_host, | 822 | /* |
367 | task, | 823 | * There are times when the SCU hardware will return an early |
368 | &request, | 824 | * response because the io request specified more data than is |
369 | isci_device, | 825 | * returned by the target device (mode pages, inquiry data, |
370 | gfp_flags | 826 | * etc.). We must check the response stats to see if this is |
371 | ); | 827 | * truly a failed request or a good request that just got |
828 | * completed early. | ||
829 | */ | ||
830 | struct ssp_response_iu *resp = &sci_req->ssp.rsp; | ||
831 | ssize_t word_cnt = SSP_RESP_IU_MAX_SIZE / sizeof(u32); | ||
832 | |||
833 | sci_swab32_cpy(&sci_req->ssp.rsp, | ||
834 | &sci_req->ssp.rsp, | ||
835 | word_cnt); | ||
836 | |||
837 | if (resp->status == 0) { | ||
838 | scic_sds_request_set_status( | ||
839 | sci_req, | ||
840 | SCU_TASK_DONE_GOOD, | ||
841 | SCI_SUCCESS_IO_DONE_EARLY); | ||
842 | } else { | ||
843 | scic_sds_request_set_status( | ||
844 | sci_req, | ||
845 | SCU_TASK_DONE_CHECK_RESPONSE, | ||
846 | SCI_FAILURE_IO_RESPONSE_VALID); | ||
847 | } | ||
848 | } | ||
849 | break; | ||
372 | 850 | ||
373 | if (ret) | 851 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_CHECK_RESPONSE): |
374 | goto out; | 852 | { |
853 | ssize_t word_cnt = SSP_RESP_IU_MAX_SIZE / sizeof(u32); | ||
375 | 854 | ||
376 | status = isci_io_request_build(isci_host, request, isci_device); | 855 | sci_swab32_cpy(&sci_req->ssp.rsp, |
377 | if (status != SCI_SUCCESS) { | 856 | &sci_req->ssp.rsp, |
378 | dev_warn(&isci_host->pdev->dev, | 857 | word_cnt); |
379 | "%s: request_construct failed - status = 0x%x\n", | 858 | |
380 | __func__, | 859 | scic_sds_request_set_status(sci_req, |
381 | status); | 860 | SCU_TASK_DONE_CHECK_RESPONSE, |
382 | goto out; | 861 | SCI_FAILURE_IO_RESPONSE_VALID); |
862 | break; | ||
383 | } | 863 | } |
384 | 864 | ||
385 | spin_lock_irqsave(&isci_host->scic_lock, flags); | 865 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_RESP_LEN_ERR): |
866 | /* | ||
867 | * / @todo With TASK_DONE_RESP_LEN_ERR is the response frame | ||
868 | * guaranteed to be received before this completion status is | ||
869 | * posted? | ||
870 | */ | ||
871 | resp_iu = &sci_req->ssp.rsp; | ||
872 | datapres = resp_iu->datapres; | ||
873 | |||
874 | if ((datapres == 0x01) || (datapres == 0x02)) { | ||
875 | scic_sds_request_set_status( | ||
876 | sci_req, | ||
877 | SCU_TASK_DONE_CHECK_RESPONSE, | ||
878 | SCI_FAILURE_IO_RESPONSE_VALID); | ||
879 | } else | ||
880 | scic_sds_request_set_status( | ||
881 | sci_req, SCU_TASK_DONE_GOOD, SCI_SUCCESS); | ||
882 | break; | ||
386 | 883 | ||
387 | /* send the request, let the core assign the IO TAG. */ | 884 | /* only stp device gets suspended. */ |
388 | status = scic_controller_start_io(&isci_host->sci, sci_device, | 885 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_ACK_NAK_TO): |
389 | &request->sci, | 886 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_LL_PERR): |
390 | SCI_CONTROLLER_INVALID_IO_TAG); | 887 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_NAK_ERR): |
391 | if (status != SCI_SUCCESS && | 888 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_DATA_LEN_ERR): |
392 | status != SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED) { | 889 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_LL_ABORT_ERR): |
393 | dev_warn(&isci_host->pdev->dev, | 890 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_XR_WD_LEN): |
394 | "%s: failed request start (0x%x)\n", | 891 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_MAX_PLD_ERR): |
395 | __func__, status); | 892 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_UNEXP_RESP): |
396 | spin_unlock_irqrestore(&isci_host->scic_lock, flags); | 893 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_UNEXP_SDBFIS): |
397 | goto out; | 894 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_REG_ERR): |
895 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SDB_ERR): | ||
896 | if (sci_req->protocol == SCIC_STP_PROTOCOL) { | ||
897 | scic_sds_request_set_status( | ||
898 | sci_req, | ||
899 | SCU_GET_COMPLETION_TL_STATUS(completion_code) >> | ||
900 | SCU_COMPLETION_TL_STATUS_SHIFT, | ||
901 | SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED); | ||
902 | } else { | ||
903 | scic_sds_request_set_status( | ||
904 | sci_req, | ||
905 | SCU_GET_COMPLETION_TL_STATUS(completion_code) >> | ||
906 | SCU_COMPLETION_TL_STATUS_SHIFT, | ||
907 | SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR); | ||
908 | } | ||
909 | break; | ||
910 | |||
911 | /* both stp/ssp device gets suspended */ | ||
912 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_LF_ERR): | ||
913 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_WRONG_DESTINATION): | ||
914 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_RESERVED_ABANDON_1): | ||
915 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_RESERVED_ABANDON_2): | ||
916 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_RESERVED_ABANDON_3): | ||
917 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_BAD_DESTINATION): | ||
918 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_ZONE_VIOLATION): | ||
919 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_STP_RESOURCES_BUSY): | ||
920 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_PROTOCOL_NOT_SUPPORTED): | ||
921 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_OPEN_REJECT_CONNECTION_RATE_NOT_SUPPORTED): | ||
922 | scic_sds_request_set_status( | ||
923 | sci_req, | ||
924 | SCU_GET_COMPLETION_TL_STATUS(completion_code) >> | ||
925 | SCU_COMPLETION_TL_STATUS_SHIFT, | ||
926 | SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED); | ||
927 | break; | ||
928 | |||
929 | /* neither ssp nor stp gets suspended. */ | ||
930 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_NAK_CMD_ERR): | ||
931 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_UNEXP_XR): | ||
932 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_XR_IU_LEN_ERR): | ||
933 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SDMA_ERR): | ||
934 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_OFFSET_ERR): | ||
935 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_EXCESS_DATA): | ||
936 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SMP_RESP_TO_ERR): | ||
937 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SMP_UFI_ERR): | ||
938 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SMP_FRM_TYPE_ERR): | ||
939 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_SMP_LL_RX_ERR): | ||
940 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_UNEXP_DATA): | ||
941 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_OPEN_FAIL): | ||
942 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_VIIT_ENTRY_NV): | ||
943 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_IIT_ENTRY_NV): | ||
944 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_RNCNV_OUTBOUND): | ||
945 | default: | ||
946 | scic_sds_request_set_status( | ||
947 | sci_req, | ||
948 | SCU_GET_COMPLETION_TL_STATUS(completion_code) >> | ||
949 | SCU_COMPLETION_TL_STATUS_SHIFT, | ||
950 | SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR); | ||
951 | break; | ||
398 | } | 952 | } |
399 | 953 | ||
400 | /* Either I/O started OK, or the core has signaled that | 954 | /* |
401 | * the device needs a target reset. | 955 | * TODO: This is probably wrong for ACK/NAK timeout conditions |
402 | * | ||
403 | * In either case, hold onto the I/O for later. | ||
404 | * | ||
405 | * Update it's status and add it to the list in the | ||
406 | * remote device object. | ||
407 | */ | 956 | */ |
408 | isci_request_change_state(request, started); | ||
409 | list_add(&request->dev_node, &isci_device->reqs_in_process); | ||
410 | 957 | ||
411 | if (status == SCI_SUCCESS) { | 958 | /* In all cases we will treat this as the completion of the IO req. */ |
412 | /* Save the tag for possible task mgmt later. */ | 959 | sci_base_state_machine_change_state( |
413 | request->io_tag = scic_io_request_get_io_tag(&request->sci); | 960 | &sci_req->state_machine, |
961 | SCI_BASE_REQUEST_STATE_COMPLETED); | ||
962 | return SCI_SUCCESS; | ||
963 | } | ||
964 | |||
965 | enum sci_status | ||
966 | scic_sds_io_request_tc_completion(struct scic_sds_request *request, u32 completion_code) | ||
967 | { | ||
968 | if (request->state_machine.current_state_id == SCI_BASE_REQUEST_STATE_STARTED && | ||
969 | request->has_started_substate_machine == false) | ||
970 | return scic_sds_request_started_state_tc_completion_handler(request, completion_code); | ||
971 | else if (request->state_handlers->tc_completion_handler) | ||
972 | return request->state_handlers->tc_completion_handler(request, completion_code); | ||
973 | |||
974 | dev_warn(scic_to_dev(request->owning_controller), | ||
975 | "%s: SCIC IO Request given task completion notification %x " | ||
976 | "while in wrong state %d\n", | ||
977 | __func__, | ||
978 | completion_code, | ||
979 | sci_base_state_machine_get_state(&request->state_machine)); | ||
980 | |||
981 | return SCI_FAILURE_INVALID_STATE; | ||
982 | |||
983 | } | ||
984 | |||
985 | /* | ||
986 | * This method implements the action to be taken when an SCIC_SDS_IO_REQUEST_T | ||
987 | * object receives a scic_sds_request_frame_handler() request. This method | ||
988 | * first determines the frame type received. If this is a response frame then | ||
989 | * the response data is copied to the io request response buffer for processing | ||
990 | * at completion time. If the frame type is not a response buffer an error is | ||
991 | * logged. enum sci_status SCI_SUCCESS SCI_FAILURE_INVALID_PARAMETER_VALUE | ||
992 | */ | ||
993 | static enum sci_status | ||
994 | scic_sds_request_started_state_frame_handler(struct scic_sds_request *sci_req, | ||
995 | u32 frame_index) | ||
996 | { | ||
997 | enum sci_status status; | ||
998 | u32 *frame_header; | ||
999 | struct ssp_frame_hdr ssp_hdr; | ||
1000 | ssize_t word_cnt; | ||
1001 | |||
1002 | status = scic_sds_unsolicited_frame_control_get_header( | ||
1003 | &(scic_sds_request_get_controller(sci_req)->uf_control), | ||
1004 | frame_index, | ||
1005 | (void **)&frame_header); | ||
1006 | |||
1007 | word_cnt = sizeof(struct ssp_frame_hdr) / sizeof(u32); | ||
1008 | sci_swab32_cpy(&ssp_hdr, frame_header, word_cnt); | ||
1009 | |||
1010 | if (ssp_hdr.frame_type == SSP_RESPONSE) { | ||
1011 | struct ssp_response_iu *resp_iu; | ||
1012 | ssize_t word_cnt = SSP_RESP_IU_MAX_SIZE / sizeof(u32); | ||
1013 | |||
1014 | status = scic_sds_unsolicited_frame_control_get_buffer( | ||
1015 | &(scic_sds_request_get_controller(sci_req)->uf_control), | ||
1016 | frame_index, | ||
1017 | (void **)&resp_iu); | ||
1018 | |||
1019 | sci_swab32_cpy(&sci_req->ssp.rsp, | ||
1020 | resp_iu, word_cnt); | ||
1021 | |||
1022 | resp_iu = &sci_req->ssp.rsp; | ||
1023 | |||
1024 | if ((resp_iu->datapres == 0x01) || | ||
1025 | (resp_iu->datapres == 0x02)) { | ||
1026 | scic_sds_request_set_status( | ||
1027 | sci_req, | ||
1028 | SCU_TASK_DONE_CHECK_RESPONSE, | ||
1029 | SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR); | ||
1030 | } else | ||
1031 | scic_sds_request_set_status( | ||
1032 | sci_req, SCU_TASK_DONE_GOOD, SCI_SUCCESS); | ||
414 | } else { | 1033 | } else { |
415 | /* The request did not really start in the | 1034 | /* This was not a response frame why did it get forwarded? */ |
416 | * hardware, so clear the request handle | 1035 | dev_err(scic_to_dev(sci_req->owning_controller), |
417 | * here so no terminations will be done. | 1036 | "%s: SCIC IO Request 0x%p received unexpected " |
418 | */ | 1037 | "frame %d type 0x%02x\n", |
419 | request->terminated = true; | 1038 | __func__, |
1039 | sci_req, | ||
1040 | frame_index, | ||
1041 | ssp_hdr.frame_type); | ||
420 | } | 1042 | } |
421 | spin_unlock_irqrestore(&isci_host->scic_lock, flags); | ||
422 | 1043 | ||
423 | if (status == | 1044 | /* |
424 | SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED) { | 1045 | * In any case we are done with this frame buffer return it to the |
425 | /* Signal libsas that we need the SCSI error | 1046 | * controller |
426 | * handler thread to work on this I/O and that | 1047 | */ |
427 | * we want a device reset. | 1048 | scic_sds_controller_release_frame( |
428 | */ | 1049 | sci_req->owning_controller, frame_index); |
429 | spin_lock_irqsave(&task->task_state_lock, flags); | ||
430 | task->task_state_flags |= SAS_TASK_NEED_DEV_RESET; | ||
431 | spin_unlock_irqrestore(&task->task_state_lock, flags); | ||
432 | 1050 | ||
433 | /* Cause this task to be scheduled in the SCSI error | 1051 | return SCI_SUCCESS; |
434 | * handler thread. | 1052 | } |
435 | */ | ||
436 | isci_execpath_callback(isci_host, task, | ||
437 | sas_task_abort); | ||
438 | 1053 | ||
439 | /* Change the status, since we are holding | 1054 | /* |
440 | * the I/O until it is managed by the SCSI | 1055 | * ***************************************************************************** |
441 | * error handler. | 1056 | * * COMPLETED STATE HANDLERS |
442 | */ | 1057 | * ***************************************************************************** */ |
443 | status = SCI_SUCCESS; | 1058 | |
1059 | |||
1060 | /* | ||
1061 | * This method implements the action to be taken when an SCIC_SDS_IO_REQUEST_T | ||
1062 | * object receives a scic_sds_request_complete() request. This method frees up | ||
1063 | * any io request resources that have been allocated and transitions the | ||
1064 | * request to its final state. Consider stopping the state machine instead of | ||
1065 | * transitioning to the final state? enum sci_status SCI_SUCCESS | ||
1066 | */ | ||
1067 | static enum sci_status scic_sds_request_completed_state_complete_handler( | ||
1068 | struct scic_sds_request *request) | ||
1069 | { | ||
1070 | if (request->was_tag_assigned_by_user != true) { | ||
1071 | scic_controller_free_io_tag( | ||
1072 | request->owning_controller, request->io_tag); | ||
444 | } | 1073 | } |
445 | 1074 | ||
446 | out: | 1075 | if (request->saved_rx_frame_index != SCU_INVALID_FRAME_INDEX) { |
447 | if (status != SCI_SUCCESS) { | 1076 | scic_sds_controller_release_frame( |
448 | /* release dma memory on failure. */ | 1077 | request->owning_controller, request->saved_rx_frame_index); |
449 | isci_request_free(isci_host, request); | ||
450 | request = NULL; | ||
451 | ret = SCI_FAILURE; | ||
452 | } | 1078 | } |
453 | 1079 | ||
454 | *isci_request = request; | 1080 | sci_base_state_machine_change_state(&request->state_machine, |
455 | return ret; | 1081 | SCI_BASE_REQUEST_STATE_FINAL); |
1082 | return SCI_SUCCESS; | ||
1083 | } | ||
1084 | |||
1085 | /* | ||
1086 | * ***************************************************************************** | ||
1087 | * * ABORTING STATE HANDLERS | ||
1088 | * ***************************************************************************** */ | ||
1089 | |||
1090 | /* | ||
1091 | * This method implements the action to be taken when an SCIC_SDS_IO_REQUEST_T | ||
1092 | * object receives a scic_sds_request_terminate() request. This method is the | ||
1093 | * io request aborting state abort handlers. On receipt of a multiple | ||
1094 | * terminate requests the io request will transition to the completed state. | ||
1095 | * This should not happen in normal operation. enum sci_status SCI_SUCCESS | ||
1096 | */ | ||
1097 | static enum sci_status scic_sds_request_aborting_state_abort_handler( | ||
1098 | struct scic_sds_request *request) | ||
1099 | { | ||
1100 | sci_base_state_machine_change_state(&request->state_machine, | ||
1101 | SCI_BASE_REQUEST_STATE_COMPLETED); | ||
1102 | return SCI_SUCCESS; | ||
1103 | } | ||
1104 | |||
1105 | /* | ||
1106 | * This method implements the action to be taken when an SCIC_SDS_IO_REQUEST_T | ||
1107 | * object receives a scic_sds_request_task_completion() request. This method | ||
1108 | * decodes the completion type waiting for the abort task complete | ||
1109 | * notification. When the abort task complete is received the io request | ||
1110 | * transitions to the completed state. enum sci_status SCI_SUCCESS | ||
1111 | */ | ||
1112 | static enum sci_status scic_sds_request_aborting_state_tc_completion_handler( | ||
1113 | struct scic_sds_request *sci_req, | ||
1114 | u32 completion_code) | ||
1115 | { | ||
1116 | switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) { | ||
1117 | case (SCU_TASK_DONE_GOOD << SCU_COMPLETION_TL_STATUS_SHIFT): | ||
1118 | case (SCU_TASK_DONE_TASK_ABORT << SCU_COMPLETION_TL_STATUS_SHIFT): | ||
1119 | scic_sds_request_set_status( | ||
1120 | sci_req, SCU_TASK_DONE_TASK_ABORT, SCI_FAILURE_IO_TERMINATED | ||
1121 | ); | ||
1122 | |||
1123 | sci_base_state_machine_change_state(&sci_req->state_machine, | ||
1124 | SCI_BASE_REQUEST_STATE_COMPLETED); | ||
1125 | break; | ||
1126 | |||
1127 | default: | ||
1128 | /* | ||
1129 | * Unless we get some strange error wait for the task abort to complete | ||
1130 | * TODO: Should there be a state change for this completion? */ | ||
1131 | break; | ||
1132 | } | ||
1133 | |||
1134 | return SCI_SUCCESS; | ||
1135 | } | ||
1136 | |||
1137 | /* | ||
1138 | * This method implements the action to be taken when an SCIC_SDS_IO_REQUEST_T | ||
1139 | * object receives a scic_sds_request_frame_handler() request. This method | ||
1140 | * discards the unsolicited frame since we are waiting for the abort task | ||
1141 | * completion. enum sci_status SCI_SUCCESS | ||
1142 | */ | ||
1143 | static enum sci_status scic_sds_request_aborting_state_frame_handler( | ||
1144 | struct scic_sds_request *sci_req, | ||
1145 | u32 frame_index) | ||
1146 | { | ||
1147 | /* TODO: Is it even possible to get an unsolicited frame in the aborting state? */ | ||
1148 | |||
1149 | scic_sds_controller_release_frame( | ||
1150 | sci_req->owning_controller, frame_index); | ||
1151 | |||
1152 | return SCI_SUCCESS; | ||
456 | } | 1153 | } |
457 | 1154 | ||
1155 | static const struct scic_sds_io_request_state_handler scic_sds_request_state_handler_table[] = { | ||
1156 | [SCI_BASE_REQUEST_STATE_INITIAL] = { | ||
1157 | }, | ||
1158 | [SCI_BASE_REQUEST_STATE_CONSTRUCTED] = { | ||
1159 | .start_handler = scic_sds_request_constructed_state_start_handler, | ||
1160 | .abort_handler = scic_sds_request_constructed_state_abort_handler, | ||
1161 | }, | ||
1162 | [SCI_BASE_REQUEST_STATE_STARTED] = { | ||
1163 | .abort_handler = scic_sds_request_started_state_abort_handler, | ||
1164 | .tc_completion_handler = scic_sds_request_started_state_tc_completion_handler, | ||
1165 | .frame_handler = scic_sds_request_started_state_frame_handler, | ||
1166 | }, | ||
1167 | [SCI_BASE_REQUEST_STATE_COMPLETED] = { | ||
1168 | .complete_handler = scic_sds_request_completed_state_complete_handler, | ||
1169 | }, | ||
1170 | [SCI_BASE_REQUEST_STATE_ABORTING] = { | ||
1171 | .abort_handler = scic_sds_request_aborting_state_abort_handler, | ||
1172 | .tc_completion_handler = scic_sds_request_aborting_state_tc_completion_handler, | ||
1173 | .frame_handler = scic_sds_request_aborting_state_frame_handler, | ||
1174 | }, | ||
1175 | [SCI_BASE_REQUEST_STATE_FINAL] = { | ||
1176 | }, | ||
1177 | }; | ||
1178 | |||
458 | 1179 | ||
459 | /** | 1180 | /** |
460 | * isci_request_process_response_iu() - This function sets the status and | 1181 | * isci_request_process_response_iu() - This function sets the status and |
@@ -541,7 +1262,7 @@ static void isci_request_handle_controller_specific_errors( | |||
541 | { | 1262 | { |
542 | unsigned int cstatus; | 1263 | unsigned int cstatus; |
543 | 1264 | ||
544 | cstatus = scic_request_get_controller_status(&request->sci); | 1265 | cstatus = request->sci.scu_status; |
545 | 1266 | ||
546 | dev_dbg(&request->isci_host->pdev->dev, | 1267 | dev_dbg(&request->isci_host->pdev->dev, |
547 | "%s: %p SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR " | 1268 | "%s: %p SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR " |
@@ -833,20 +1554,9 @@ static void isci_task_save_for_upper_layer_completion( | |||
833 | } | 1554 | } |
834 | } | 1555 | } |
835 | 1556 | ||
836 | /** | 1557 | static void isci_request_io_request_complete(struct isci_host *isci_host, |
837 | * isci_request_io_request_complete() - This function is called by the sci core | 1558 | struct isci_request *request, |
838 | * when an io request completes. | 1559 | enum sci_io_status completion_status) |
839 | * @isci_host: This parameter specifies the ISCI host object | ||
840 | * @request: This parameter is the completed isci_request object. | ||
841 | * @completion_status: This parameter specifies the completion status from the | ||
842 | * sci core. | ||
843 | * | ||
844 | * none. | ||
845 | */ | ||
846 | void isci_request_io_request_complete( | ||
847 | struct isci_host *isci_host, | ||
848 | struct isci_request *request, | ||
849 | enum sci_io_status completion_status) | ||
850 | { | 1560 | { |
851 | struct sas_task *task = isci_request_access_task(request); | 1561 | struct sas_task *task = isci_request_access_task(request); |
852 | struct ssp_response_iu *resp_iu; | 1562 | struct ssp_response_iu *resp_iu; |
@@ -1035,8 +1745,7 @@ void isci_request_io_request_complete( | |||
1035 | * There is a possibility that less data than | 1745 | * There is a possibility that less data than |
1036 | * the maximum was transferred. | 1746 | * the maximum was transferred. |
1037 | */ | 1747 | */ |
1038 | u32 transferred_length | 1748 | u32 transferred_length = sci_req_tx_bytes(&request->sci); |
1039 | = scic_io_request_get_number_of_bytes_transferred(&request->sci); | ||
1040 | 1749 | ||
1041 | task->task_status.residual | 1750 | task->task_status.residual |
1042 | = task->total_xfer_len - transferred_length; | 1751 | = task->total_xfer_len - transferred_length; |
@@ -1158,3 +1867,680 @@ void isci_request_io_request_complete( | |||
1158 | 1867 | ||
1159 | isci_host_can_dequeue(isci_host, 1); | 1868 | isci_host_can_dequeue(isci_host, 1); |
1160 | } | 1869 | } |
1870 | |||
1871 | /** | ||
1872 | * scic_sds_request_initial_state_enter() - | ||
1873 | * @object: This parameter specifies the base object for which the state | ||
1874 | * transition is occurring. | ||
1875 | * | ||
1876 | * This method implements the actions taken when entering the | ||
1877 | * SCI_BASE_REQUEST_STATE_INITIAL state. This state is entered when the initial | ||
1878 | * base request is constructed. Entry into the initial state sets all handlers | ||
1879 | * for the io request object to their default handlers. none | ||
1880 | */ | ||
1881 | static void scic_sds_request_initial_state_enter(void *object) | ||
1882 | { | ||
1883 | struct scic_sds_request *sci_req = object; | ||
1884 | |||
1885 | SET_STATE_HANDLER( | ||
1886 | sci_req, | ||
1887 | scic_sds_request_state_handler_table, | ||
1888 | SCI_BASE_REQUEST_STATE_INITIAL | ||
1889 | ); | ||
1890 | } | ||
1891 | |||
1892 | /** | ||
1893 | * scic_sds_request_constructed_state_enter() - | ||
1894 | * @object: The io request object that is to enter the constructed state. | ||
1895 | * | ||
1896 | * This method implements the actions taken when entering the | ||
1897 | * SCI_BASE_REQUEST_STATE_CONSTRUCTED state. The method sets the state handlers | ||
1898 | * for the the constructed state. none | ||
1899 | */ | ||
1900 | static void scic_sds_request_constructed_state_enter(void *object) | ||
1901 | { | ||
1902 | struct scic_sds_request *sci_req = object; | ||
1903 | |||
1904 | SET_STATE_HANDLER( | ||
1905 | sci_req, | ||
1906 | scic_sds_request_state_handler_table, | ||
1907 | SCI_BASE_REQUEST_STATE_CONSTRUCTED | ||
1908 | ); | ||
1909 | } | ||
1910 | |||
1911 | /** | ||
1912 | * scic_sds_request_started_state_enter() - | ||
1913 | * @object: This parameter specifies the base object for which the state | ||
1914 | * transition is occurring. This is cast into a SCIC_SDS_IO_REQUEST object. | ||
1915 | * | ||
1916 | * This method implements the actions taken when entering the | ||
1917 | * SCI_BASE_REQUEST_STATE_STARTED state. If the io request object type is a | ||
1918 | * SCSI Task request we must enter the started substate machine. none | ||
1919 | */ | ||
1920 | static void scic_sds_request_started_state_enter(void *object) | ||
1921 | { | ||
1922 | struct scic_sds_request *sci_req = object; | ||
1923 | |||
1924 | SET_STATE_HANDLER( | ||
1925 | sci_req, | ||
1926 | scic_sds_request_state_handler_table, | ||
1927 | SCI_BASE_REQUEST_STATE_STARTED | ||
1928 | ); | ||
1929 | |||
1930 | /* | ||
1931 | * Most of the request state machines have a started substate machine so | ||
1932 | * start its execution on the entry to the started state. */ | ||
1933 | if (sci_req->has_started_substate_machine == true) | ||
1934 | sci_base_state_machine_start(&sci_req->started_substate_machine); | ||
1935 | } | ||
1936 | |||
1937 | /** | ||
1938 | * scic_sds_request_started_state_exit() - | ||
1939 | * @object: This parameter specifies the base object for which the state | ||
1940 | * transition is occurring. This object is cast into a SCIC_SDS_IO_REQUEST | ||
1941 | * object. | ||
1942 | * | ||
1943 | * This method implements the actions taken when exiting the | ||
1944 | * SCI_BASE_REQUEST_STATE_STARTED state. For task requests the action will be | ||
1945 | * to stop the started substate machine. none | ||
1946 | */ | ||
1947 | static void scic_sds_request_started_state_exit(void *object) | ||
1948 | { | ||
1949 | struct scic_sds_request *sci_req = object; | ||
1950 | |||
1951 | if (sci_req->has_started_substate_machine == true) | ||
1952 | sci_base_state_machine_stop(&sci_req->started_substate_machine); | ||
1953 | } | ||
1954 | |||
1955 | /** | ||
1956 | * scic_sds_request_completed_state_enter() - | ||
1957 | * @object: This parameter specifies the base object for which the state | ||
1958 | * transition is occurring. This object is cast into a SCIC_SDS_IO_REQUEST | ||
1959 | * object. | ||
1960 | * | ||
1961 | * This method implements the actions taken when entering the | ||
1962 | * SCI_BASE_REQUEST_STATE_COMPLETED state. This state is entered when the | ||
1963 | * SCIC_SDS_IO_REQUEST has completed. The method will decode the request | ||
1964 | * completion status and convert it to an enum sci_status to return in the | ||
1965 | * completion callback function. none | ||
1966 | */ | ||
1967 | static void scic_sds_request_completed_state_enter(void *object) | ||
1968 | { | ||
1969 | struct scic_sds_request *sci_req = object; | ||
1970 | struct scic_sds_controller *scic = | ||
1971 | scic_sds_request_get_controller(sci_req); | ||
1972 | struct isci_host *ihost = scic_to_ihost(scic); | ||
1973 | struct isci_request *ireq = sci_req_to_ireq(sci_req); | ||
1974 | |||
1975 | SET_STATE_HANDLER(sci_req, | ||
1976 | scic_sds_request_state_handler_table, | ||
1977 | SCI_BASE_REQUEST_STATE_COMPLETED); | ||
1978 | |||
1979 | /* Tell the SCI_USER that the IO request is complete */ | ||
1980 | if (sci_req->is_task_management_request == false) | ||
1981 | isci_request_io_request_complete(ihost, ireq, | ||
1982 | sci_req->sci_status); | ||
1983 | else | ||
1984 | isci_task_request_complete(ihost, ireq, sci_req->sci_status); | ||
1985 | } | ||
1986 | |||
1987 | /** | ||
1988 | * scic_sds_request_aborting_state_enter() - | ||
1989 | * @object: This parameter specifies the base object for which the state | ||
1990 | * transition is occurring. This object is cast into a SCIC_SDS_IO_REQUEST | ||
1991 | * object. | ||
1992 | * | ||
1993 | * This method implements the actions taken when entering the | ||
1994 | * SCI_BASE_REQUEST_STATE_ABORTING state. none | ||
1995 | */ | ||
1996 | static void scic_sds_request_aborting_state_enter(void *object) | ||
1997 | { | ||
1998 | struct scic_sds_request *sci_req = object; | ||
1999 | |||
2000 | /* Setting the abort bit in the Task Context is required by the silicon. */ | ||
2001 | sci_req->task_context_buffer->abort = 1; | ||
2002 | |||
2003 | SET_STATE_HANDLER( | ||
2004 | sci_req, | ||
2005 | scic_sds_request_state_handler_table, | ||
2006 | SCI_BASE_REQUEST_STATE_ABORTING | ||
2007 | ); | ||
2008 | } | ||
2009 | |||
2010 | /** | ||
2011 | * scic_sds_request_final_state_enter() - | ||
2012 | * @object: This parameter specifies the base object for which the state | ||
2013 | * transition is occurring. This is cast into a SCIC_SDS_IO_REQUEST object. | ||
2014 | * | ||
2015 | * This method implements the actions taken when entering the | ||
2016 | * SCI_BASE_REQUEST_STATE_FINAL state. The only action required is to put the | ||
2017 | * state handlers in place. none | ||
2018 | */ | ||
2019 | static void scic_sds_request_final_state_enter(void *object) | ||
2020 | { | ||
2021 | struct scic_sds_request *sci_req = object; | ||
2022 | |||
2023 | SET_STATE_HANDLER( | ||
2024 | sci_req, | ||
2025 | scic_sds_request_state_handler_table, | ||
2026 | SCI_BASE_REQUEST_STATE_FINAL | ||
2027 | ); | ||
2028 | } | ||
2029 | |||
2030 | static const struct sci_base_state scic_sds_request_state_table[] = { | ||
2031 | [SCI_BASE_REQUEST_STATE_INITIAL] = { | ||
2032 | .enter_state = scic_sds_request_initial_state_enter, | ||
2033 | }, | ||
2034 | [SCI_BASE_REQUEST_STATE_CONSTRUCTED] = { | ||
2035 | .enter_state = scic_sds_request_constructed_state_enter, | ||
2036 | }, | ||
2037 | [SCI_BASE_REQUEST_STATE_STARTED] = { | ||
2038 | .enter_state = scic_sds_request_started_state_enter, | ||
2039 | .exit_state = scic_sds_request_started_state_exit | ||
2040 | }, | ||
2041 | [SCI_BASE_REQUEST_STATE_COMPLETED] = { | ||
2042 | .enter_state = scic_sds_request_completed_state_enter, | ||
2043 | }, | ||
2044 | [SCI_BASE_REQUEST_STATE_ABORTING] = { | ||
2045 | .enter_state = scic_sds_request_aborting_state_enter, | ||
2046 | }, | ||
2047 | [SCI_BASE_REQUEST_STATE_FINAL] = { | ||
2048 | .enter_state = scic_sds_request_final_state_enter, | ||
2049 | }, | ||
2050 | }; | ||
2051 | |||
2052 | static void scic_sds_general_request_construct(struct scic_sds_controller *scic, | ||
2053 | struct scic_sds_remote_device *sci_dev, | ||
2054 | u16 io_tag, struct scic_sds_request *sci_req) | ||
2055 | { | ||
2056 | sci_base_state_machine_construct(&sci_req->state_machine, sci_req, | ||
2057 | scic_sds_request_state_table, SCI_BASE_REQUEST_STATE_INITIAL); | ||
2058 | sci_base_state_machine_start(&sci_req->state_machine); | ||
2059 | |||
2060 | sci_req->io_tag = io_tag; | ||
2061 | sci_req->owning_controller = scic; | ||
2062 | sci_req->target_device = sci_dev; | ||
2063 | sci_req->has_started_substate_machine = false; | ||
2064 | sci_req->protocol = SCIC_NO_PROTOCOL; | ||
2065 | sci_req->saved_rx_frame_index = SCU_INVALID_FRAME_INDEX; | ||
2066 | sci_req->device_sequence = scic_sds_remote_device_get_sequence(sci_dev); | ||
2067 | |||
2068 | sci_req->sci_status = SCI_SUCCESS; | ||
2069 | sci_req->scu_status = 0; | ||
2070 | sci_req->post_context = 0xFFFFFFFF; | ||
2071 | |||
2072 | sci_req->is_task_management_request = false; | ||
2073 | |||
2074 | if (io_tag == SCI_CONTROLLER_INVALID_IO_TAG) { | ||
2075 | sci_req->was_tag_assigned_by_user = false; | ||
2076 | sci_req->task_context_buffer = NULL; | ||
2077 | } else { | ||
2078 | sci_req->was_tag_assigned_by_user = true; | ||
2079 | |||
2080 | sci_req->task_context_buffer = | ||
2081 | scic_sds_controller_get_task_context_buffer(scic, io_tag); | ||
2082 | } | ||
2083 | } | ||
2084 | |||
2085 | static enum sci_status | ||
2086 | scic_io_request_construct(struct scic_sds_controller *scic, | ||
2087 | struct scic_sds_remote_device *sci_dev, | ||
2088 | u16 io_tag, struct scic_sds_request *sci_req) | ||
2089 | { | ||
2090 | struct domain_device *dev = sci_dev_to_domain(sci_dev); | ||
2091 | enum sci_status status = SCI_SUCCESS; | ||
2092 | |||
2093 | /* Build the common part of the request */ | ||
2094 | scic_sds_general_request_construct(scic, sci_dev, io_tag, sci_req); | ||
2095 | |||
2096 | if (sci_dev->rnc.remote_node_index == | ||
2097 | SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX) | ||
2098 | return SCI_FAILURE_INVALID_REMOTE_DEVICE; | ||
2099 | |||
2100 | if (dev->dev_type == SAS_END_DEV) | ||
2101 | scic_sds_ssp_io_request_assign_buffers(sci_req); | ||
2102 | else if ((dev->dev_type == SATA_DEV) || | ||
2103 | (dev->tproto & SAS_PROTOCOL_STP)) { | ||
2104 | scic_sds_stp_request_assign_buffers(sci_req); | ||
2105 | memset(&sci_req->stp.cmd, 0, sizeof(sci_req->stp.cmd)); | ||
2106 | } else if (dev_is_expander(dev)) { | ||
2107 | scic_sds_smp_request_assign_buffers(sci_req); | ||
2108 | memset(&sci_req->smp.cmd, 0, sizeof(sci_req->smp.cmd)); | ||
2109 | } else | ||
2110 | status = SCI_FAILURE_UNSUPPORTED_PROTOCOL; | ||
2111 | |||
2112 | if (status == SCI_SUCCESS) { | ||
2113 | memset(sci_req->task_context_buffer, 0, | ||
2114 | offsetof(struct scu_task_context, sgl_pair_ab)); | ||
2115 | } | ||
2116 | |||
2117 | return status; | ||
2118 | } | ||
2119 | |||
2120 | enum sci_status scic_task_request_construct(struct scic_sds_controller *scic, | ||
2121 | struct scic_sds_remote_device *sci_dev, | ||
2122 | u16 io_tag, struct scic_sds_request *sci_req) | ||
2123 | { | ||
2124 | struct domain_device *dev = sci_dev_to_domain(sci_dev); | ||
2125 | enum sci_status status = SCI_SUCCESS; | ||
2126 | |||
2127 | /* Build the common part of the request */ | ||
2128 | scic_sds_general_request_construct(scic, sci_dev, io_tag, sci_req); | ||
2129 | |||
2130 | if (dev->dev_type == SAS_END_DEV) { | ||
2131 | scic_sds_ssp_task_request_assign_buffers(sci_req); | ||
2132 | |||
2133 | sci_req->has_started_substate_machine = true; | ||
2134 | |||
2135 | /* Construct the started sub-state machine. */ | ||
2136 | sci_base_state_machine_construct( | ||
2137 | &sci_req->started_substate_machine, | ||
2138 | sci_req, | ||
2139 | scic_sds_io_request_started_task_mgmt_substate_table, | ||
2140 | SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION | ||
2141 | ); | ||
2142 | } else if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) | ||
2143 | scic_sds_stp_request_assign_buffers(sci_req); | ||
2144 | else | ||
2145 | status = SCI_FAILURE_UNSUPPORTED_PROTOCOL; | ||
2146 | |||
2147 | if (status == SCI_SUCCESS) { | ||
2148 | sci_req->is_task_management_request = true; | ||
2149 | memset(sci_req->task_context_buffer, 0, sizeof(struct scu_task_context)); | ||
2150 | } | ||
2151 | |||
2152 | return status; | ||
2153 | } | ||
2154 | |||
2155 | static enum sci_status isci_request_ssp_request_construct( | ||
2156 | struct isci_request *request) | ||
2157 | { | ||
2158 | enum sci_status status; | ||
2159 | |||
2160 | dev_dbg(&request->isci_host->pdev->dev, | ||
2161 | "%s: request = %p\n", | ||
2162 | __func__, | ||
2163 | request); | ||
2164 | status = scic_io_request_construct_basic_ssp(&request->sci); | ||
2165 | return status; | ||
2166 | } | ||
2167 | |||
2168 | static enum sci_status isci_request_stp_request_construct( | ||
2169 | struct isci_request *request) | ||
2170 | { | ||
2171 | struct sas_task *task = isci_request_access_task(request); | ||
2172 | enum sci_status status; | ||
2173 | struct host_to_dev_fis *register_fis; | ||
2174 | |||
2175 | dev_dbg(&request->isci_host->pdev->dev, | ||
2176 | "%s: request = %p\n", | ||
2177 | __func__, | ||
2178 | request); | ||
2179 | |||
2180 | /* Get the host_to_dev_fis from the core and copy | ||
2181 | * the fis from the task into it. | ||
2182 | */ | ||
2183 | register_fis = isci_sata_task_to_fis_copy(task); | ||
2184 | |||
2185 | status = scic_io_request_construct_basic_sata(&request->sci); | ||
2186 | |||
2187 | /* Set the ncq tag in the fis, from the queue | ||
2188 | * command in the task. | ||
2189 | */ | ||
2190 | if (isci_sata_is_task_ncq(task)) { | ||
2191 | |||
2192 | isci_sata_set_ncq_tag( | ||
2193 | register_fis, | ||
2194 | task | ||
2195 | ); | ||
2196 | } | ||
2197 | |||
2198 | return status; | ||
2199 | } | ||
2200 | |||
2201 | /* | ||
2202 | * isci_smp_request_build() - This function builds the smp request. | ||
2203 | * @ireq: This parameter points to the isci_request allocated in the | ||
2204 | * request construct function. | ||
2205 | * | ||
2206 | * SCI_SUCCESS on successfull completion, or specific failure code. | ||
2207 | */ | ||
2208 | static enum sci_status isci_smp_request_build(struct isci_request *ireq) | ||
2209 | { | ||
2210 | enum sci_status status = SCI_FAILURE; | ||
2211 | struct sas_task *task = isci_request_access_task(ireq); | ||
2212 | struct scic_sds_request *sci_req = &ireq->sci; | ||
2213 | |||
2214 | dev_dbg(&ireq->isci_host->pdev->dev, | ||
2215 | "%s: request = %p\n", __func__, ireq); | ||
2216 | |||
2217 | dev_dbg(&ireq->isci_host->pdev->dev, | ||
2218 | "%s: smp_req len = %d\n", | ||
2219 | __func__, | ||
2220 | task->smp_task.smp_req.length); | ||
2221 | |||
2222 | /* copy the smp_command to the address; */ | ||
2223 | sg_copy_to_buffer(&task->smp_task.smp_req, 1, | ||
2224 | &sci_req->smp.cmd, | ||
2225 | sizeof(struct smp_req)); | ||
2226 | |||
2227 | status = scic_io_request_construct_smp(sci_req); | ||
2228 | if (status != SCI_SUCCESS) | ||
2229 | dev_warn(&ireq->isci_host->pdev->dev, | ||
2230 | "%s: failed with status = %d\n", | ||
2231 | __func__, | ||
2232 | status); | ||
2233 | |||
2234 | return status; | ||
2235 | } | ||
2236 | |||
2237 | /** | ||
2238 | * isci_io_request_build() - This function builds the io request object. | ||
2239 | * @isci_host: This parameter specifies the ISCI host object | ||
2240 | * @request: This parameter points to the isci_request object allocated in the | ||
2241 | * request construct function. | ||
2242 | * @sci_device: This parameter is the handle for the sci core's remote device | ||
2243 | * object that is the destination for this request. | ||
2244 | * | ||
2245 | * SCI_SUCCESS on successfull completion, or specific failure code. | ||
2246 | */ | ||
2247 | static enum sci_status isci_io_request_build( | ||
2248 | struct isci_host *isci_host, | ||
2249 | struct isci_request *request, | ||
2250 | struct isci_remote_device *isci_device) | ||
2251 | { | ||
2252 | enum sci_status status = SCI_SUCCESS; | ||
2253 | struct sas_task *task = isci_request_access_task(request); | ||
2254 | struct scic_sds_remote_device *sci_device = &isci_device->sci; | ||
2255 | |||
2256 | dev_dbg(&isci_host->pdev->dev, | ||
2257 | "%s: isci_device = 0x%p; request = %p, " | ||
2258 | "num_scatter = %d\n", | ||
2259 | __func__, | ||
2260 | isci_device, | ||
2261 | request, | ||
2262 | task->num_scatter); | ||
2263 | |||
2264 | /* map the sgl addresses, if present. | ||
2265 | * libata does the mapping for sata devices | ||
2266 | * before we get the request. | ||
2267 | */ | ||
2268 | if (task->num_scatter && | ||
2269 | !sas_protocol_ata(task->task_proto) && | ||
2270 | !(SAS_PROTOCOL_SMP & task->task_proto)) { | ||
2271 | |||
2272 | request->num_sg_entries = dma_map_sg( | ||
2273 | &isci_host->pdev->dev, | ||
2274 | task->scatter, | ||
2275 | task->num_scatter, | ||
2276 | task->data_dir | ||
2277 | ); | ||
2278 | |||
2279 | if (request->num_sg_entries == 0) | ||
2280 | return SCI_FAILURE_INSUFFICIENT_RESOURCES; | ||
2281 | } | ||
2282 | |||
2283 | /* build the common request object. For now, | ||
2284 | * we will let the core allocate the IO tag. | ||
2285 | */ | ||
2286 | status = scic_io_request_construct(&isci_host->sci, sci_device, | ||
2287 | SCI_CONTROLLER_INVALID_IO_TAG, | ||
2288 | &request->sci); | ||
2289 | |||
2290 | if (status != SCI_SUCCESS) { | ||
2291 | dev_warn(&isci_host->pdev->dev, | ||
2292 | "%s: failed request construct\n", | ||
2293 | __func__); | ||
2294 | return SCI_FAILURE; | ||
2295 | } | ||
2296 | |||
2297 | switch (task->task_proto) { | ||
2298 | case SAS_PROTOCOL_SMP: | ||
2299 | status = isci_smp_request_build(request); | ||
2300 | break; | ||
2301 | case SAS_PROTOCOL_SSP: | ||
2302 | status = isci_request_ssp_request_construct(request); | ||
2303 | break; | ||
2304 | case SAS_PROTOCOL_SATA: | ||
2305 | case SAS_PROTOCOL_STP: | ||
2306 | case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP: | ||
2307 | status = isci_request_stp_request_construct(request); | ||
2308 | break; | ||
2309 | default: | ||
2310 | dev_warn(&isci_host->pdev->dev, | ||
2311 | "%s: unknown protocol\n", __func__); | ||
2312 | return SCI_FAILURE; | ||
2313 | } | ||
2314 | |||
2315 | return SCI_SUCCESS; | ||
2316 | } | ||
2317 | |||
2318 | /** | ||
2319 | * isci_request_alloc_core() - This function gets the request object from the | ||
2320 | * isci_host dma cache. | ||
2321 | * @isci_host: This parameter specifies the ISCI host object | ||
2322 | * @isci_request: This parameter will contain the pointer to the new | ||
2323 | * isci_request object. | ||
2324 | * @isci_device: This parameter is the pointer to the isci remote device object | ||
2325 | * that is the destination for this request. | ||
2326 | * @gfp_flags: This parameter specifies the os allocation flags. | ||
2327 | * | ||
2328 | * SCI_SUCCESS on successfull completion, or specific failure code. | ||
2329 | */ | ||
2330 | static int isci_request_alloc_core( | ||
2331 | struct isci_host *isci_host, | ||
2332 | struct isci_request **isci_request, | ||
2333 | struct isci_remote_device *isci_device, | ||
2334 | gfp_t gfp_flags) | ||
2335 | { | ||
2336 | int ret = 0; | ||
2337 | dma_addr_t handle; | ||
2338 | struct isci_request *request; | ||
2339 | |||
2340 | |||
2341 | /* get pointer to dma memory. This actually points | ||
2342 | * to both the isci_remote_device object and the | ||
2343 | * sci object. The isci object is at the beginning | ||
2344 | * of the memory allocated here. | ||
2345 | */ | ||
2346 | request = dma_pool_alloc(isci_host->dma_pool, gfp_flags, &handle); | ||
2347 | if (!request) { | ||
2348 | dev_warn(&isci_host->pdev->dev, | ||
2349 | "%s: dma_pool_alloc returned NULL\n", __func__); | ||
2350 | return -ENOMEM; | ||
2351 | } | ||
2352 | |||
2353 | /* initialize the request object. */ | ||
2354 | spin_lock_init(&request->state_lock); | ||
2355 | request->request_daddr = handle; | ||
2356 | request->isci_host = isci_host; | ||
2357 | request->isci_device = isci_device; | ||
2358 | request->io_request_completion = NULL; | ||
2359 | request->terminated = false; | ||
2360 | |||
2361 | request->num_sg_entries = 0; | ||
2362 | |||
2363 | request->complete_in_target = false; | ||
2364 | |||
2365 | INIT_LIST_HEAD(&request->completed_node); | ||
2366 | INIT_LIST_HEAD(&request->dev_node); | ||
2367 | |||
2368 | *isci_request = request; | ||
2369 | isci_request_change_state(request, allocated); | ||
2370 | |||
2371 | return ret; | ||
2372 | } | ||
2373 | |||
2374 | static int isci_request_alloc_io( | ||
2375 | struct isci_host *isci_host, | ||
2376 | struct sas_task *task, | ||
2377 | struct isci_request **isci_request, | ||
2378 | struct isci_remote_device *isci_device, | ||
2379 | gfp_t gfp_flags) | ||
2380 | { | ||
2381 | int retval = isci_request_alloc_core(isci_host, isci_request, | ||
2382 | isci_device, gfp_flags); | ||
2383 | |||
2384 | if (!retval) { | ||
2385 | (*isci_request)->ttype_ptr.io_task_ptr = task; | ||
2386 | (*isci_request)->ttype = io_task; | ||
2387 | |||
2388 | task->lldd_task = *isci_request; | ||
2389 | } | ||
2390 | return retval; | ||
2391 | } | ||
2392 | |||
2393 | /** | ||
2394 | * isci_request_alloc_tmf() - This function gets the request object from the | ||
2395 | * isci_host dma cache and initializes the relevant fields as a sas_task. | ||
2396 | * @isci_host: This parameter specifies the ISCI host object | ||
2397 | * @sas_task: This parameter is the task struct from the upper layer driver. | ||
2398 | * @isci_request: This parameter will contain the pointer to the new | ||
2399 | * isci_request object. | ||
2400 | * @isci_device: This parameter is the pointer to the isci remote device object | ||
2401 | * that is the destination for this request. | ||
2402 | * @gfp_flags: This parameter specifies the os allocation flags. | ||
2403 | * | ||
2404 | * SCI_SUCCESS on successfull completion, or specific failure code. | ||
2405 | */ | ||
2406 | int isci_request_alloc_tmf( | ||
2407 | struct isci_host *isci_host, | ||
2408 | struct isci_tmf *isci_tmf, | ||
2409 | struct isci_request **isci_request, | ||
2410 | struct isci_remote_device *isci_device, | ||
2411 | gfp_t gfp_flags) | ||
2412 | { | ||
2413 | int retval = isci_request_alloc_core(isci_host, isci_request, | ||
2414 | isci_device, gfp_flags); | ||
2415 | |||
2416 | if (!retval) { | ||
2417 | |||
2418 | (*isci_request)->ttype_ptr.tmf_task_ptr = isci_tmf; | ||
2419 | (*isci_request)->ttype = tmf_task; | ||
2420 | } | ||
2421 | return retval; | ||
2422 | } | ||
2423 | |||
2424 | /** | ||
2425 | * isci_request_execute() - This function allocates the isci_request object, | ||
2426 | * all fills in some common fields. | ||
2427 | * @isci_host: This parameter specifies the ISCI host object | ||
2428 | * @sas_task: This parameter is the task struct from the upper layer driver. | ||
2429 | * @isci_request: This parameter will contain the pointer to the new | ||
2430 | * isci_request object. | ||
2431 | * @gfp_flags: This parameter specifies the os allocation flags. | ||
2432 | * | ||
2433 | * SCI_SUCCESS on successfull completion, or specific failure code. | ||
2434 | */ | ||
2435 | int isci_request_execute( | ||
2436 | struct isci_host *isci_host, | ||
2437 | struct sas_task *task, | ||
2438 | struct isci_request **isci_request, | ||
2439 | gfp_t gfp_flags) | ||
2440 | { | ||
2441 | int ret = 0; | ||
2442 | struct scic_sds_remote_device *sci_device; | ||
2443 | enum sci_status status = SCI_FAILURE_UNSUPPORTED_PROTOCOL; | ||
2444 | struct isci_remote_device *isci_device; | ||
2445 | struct isci_request *request; | ||
2446 | unsigned long flags; | ||
2447 | |||
2448 | isci_device = task->dev->lldd_dev; | ||
2449 | sci_device = &isci_device->sci; | ||
2450 | |||
2451 | /* do common allocation and init of request object. */ | ||
2452 | ret = isci_request_alloc_io( | ||
2453 | isci_host, | ||
2454 | task, | ||
2455 | &request, | ||
2456 | isci_device, | ||
2457 | gfp_flags | ||
2458 | ); | ||
2459 | |||
2460 | if (ret) | ||
2461 | goto out; | ||
2462 | |||
2463 | status = isci_io_request_build(isci_host, request, isci_device); | ||
2464 | if (status != SCI_SUCCESS) { | ||
2465 | dev_warn(&isci_host->pdev->dev, | ||
2466 | "%s: request_construct failed - status = 0x%x\n", | ||
2467 | __func__, | ||
2468 | status); | ||
2469 | goto out; | ||
2470 | } | ||
2471 | |||
2472 | spin_lock_irqsave(&isci_host->scic_lock, flags); | ||
2473 | |||
2474 | /* send the request, let the core assign the IO TAG. */ | ||
2475 | status = scic_controller_start_io(&isci_host->sci, sci_device, | ||
2476 | &request->sci, | ||
2477 | SCI_CONTROLLER_INVALID_IO_TAG); | ||
2478 | if (status != SCI_SUCCESS && | ||
2479 | status != SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED) { | ||
2480 | dev_warn(&isci_host->pdev->dev, | ||
2481 | "%s: failed request start (0x%x)\n", | ||
2482 | __func__, status); | ||
2483 | spin_unlock_irqrestore(&isci_host->scic_lock, flags); | ||
2484 | goto out; | ||
2485 | } | ||
2486 | |||
2487 | /* Either I/O started OK, or the core has signaled that | ||
2488 | * the device needs a target reset. | ||
2489 | * | ||
2490 | * In either case, hold onto the I/O for later. | ||
2491 | * | ||
2492 | * Update it's status and add it to the list in the | ||
2493 | * remote device object. | ||
2494 | */ | ||
2495 | isci_request_change_state(request, started); | ||
2496 | list_add(&request->dev_node, &isci_device->reqs_in_process); | ||
2497 | |||
2498 | if (status == SCI_SUCCESS) { | ||
2499 | /* Save the tag for possible task mgmt later. */ | ||
2500 | request->io_tag = request->sci.io_tag; | ||
2501 | } else { | ||
2502 | /* The request did not really start in the | ||
2503 | * hardware, so clear the request handle | ||
2504 | * here so no terminations will be done. | ||
2505 | */ | ||
2506 | request->terminated = true; | ||
2507 | } | ||
2508 | spin_unlock_irqrestore(&isci_host->scic_lock, flags); | ||
2509 | |||
2510 | if (status == | ||
2511 | SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED) { | ||
2512 | /* Signal libsas that we need the SCSI error | ||
2513 | * handler thread to work on this I/O and that | ||
2514 | * we want a device reset. | ||
2515 | */ | ||
2516 | spin_lock_irqsave(&task->task_state_lock, flags); | ||
2517 | task->task_state_flags |= SAS_TASK_NEED_DEV_RESET; | ||
2518 | spin_unlock_irqrestore(&task->task_state_lock, flags); | ||
2519 | |||
2520 | /* Cause this task to be scheduled in the SCSI error | ||
2521 | * handler thread. | ||
2522 | */ | ||
2523 | isci_execpath_callback(isci_host, task, | ||
2524 | sas_task_abort); | ||
2525 | |||
2526 | /* Change the status, since we are holding | ||
2527 | * the I/O until it is managed by the SCSI | ||
2528 | * error handler. | ||
2529 | */ | ||
2530 | status = SCI_SUCCESS; | ||
2531 | } | ||
2532 | |||
2533 | out: | ||
2534 | if (status != SCI_SUCCESS) { | ||
2535 | /* release dma memory on failure. */ | ||
2536 | isci_request_free(isci_host, request); | ||
2537 | request = NULL; | ||
2538 | ret = SCI_FAILURE; | ||
2539 | } | ||
2540 | |||
2541 | *isci_request = request; | ||
2542 | return ret; | ||
2543 | } | ||
2544 | |||
2545 | |||
2546 | |||
diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index 06786ece9bb2..932ea767c8c2 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h | |||
@@ -58,7 +58,8 @@ | |||
58 | 58 | ||
59 | #include "isci.h" | 59 | #include "isci.h" |
60 | #include "host.h" | 60 | #include "host.h" |
61 | #include "scic_sds_request.h" | 61 | #include "scu_task_context.h" |
62 | #include "stp_request.h" | ||
62 | 63 | ||
63 | /** | 64 | /** |
64 | * struct isci_request_status - This enum defines the possible states of an I/O | 65 | * struct isci_request_status - This enum defines the possible states of an I/O |
@@ -82,6 +83,151 @@ enum task_type { | |||
82 | tmf_task = 1 | 83 | tmf_task = 1 |
83 | }; | 84 | }; |
84 | 85 | ||
86 | enum sci_request_protocol { | ||
87 | SCIC_NO_PROTOCOL, | ||
88 | SCIC_SMP_PROTOCOL, | ||
89 | SCIC_SSP_PROTOCOL, | ||
90 | SCIC_STP_PROTOCOL | ||
91 | }; /* XXX remove me, use sas_task.dev instead */; | ||
92 | |||
93 | struct scic_sds_request { | ||
94 | /** | ||
95 | * This field contains the information for the base request state machine. | ||
96 | */ | ||
97 | struct sci_base_state_machine state_machine; | ||
98 | |||
99 | /** | ||
100 | * This field simply points to the controller to which this IO request | ||
101 | * is associated. | ||
102 | */ | ||
103 | struct scic_sds_controller *owning_controller; | ||
104 | |||
105 | /** | ||
106 | * This field simply points to the remote device to which this IO request | ||
107 | * is associated. | ||
108 | */ | ||
109 | struct scic_sds_remote_device *target_device; | ||
110 | |||
111 | /** | ||
112 | * This field is utilized to determine if the SCI user is managing | ||
113 | * the IO tag for this request or if the core is managing it. | ||
114 | */ | ||
115 | bool was_tag_assigned_by_user; | ||
116 | |||
117 | /** | ||
118 | * This field indicates the IO tag for this request. The IO tag is | ||
119 | * comprised of the task_index and a sequence count. The sequence count | ||
120 | * is utilized to help identify tasks from one life to another. | ||
121 | */ | ||
122 | u16 io_tag; | ||
123 | |||
124 | /** | ||
125 | * This field specifies the protocol being utilized for this | ||
126 | * IO request. | ||
127 | */ | ||
128 | enum sci_request_protocol protocol; | ||
129 | |||
130 | /** | ||
131 | * This field indicates the completion status taken from the SCUs | ||
132 | * completion code. It indicates the completion result for the SCU hardware. | ||
133 | */ | ||
134 | u32 scu_status; | ||
135 | |||
136 | /** | ||
137 | * This field indicates the completion status returned to the SCI user. It | ||
138 | * indicates the users view of the io request completion. | ||
139 | */ | ||
140 | u32 sci_status; | ||
141 | |||
142 | /** | ||
143 | * This field contains the value to be utilized when posting (e.g. Post_TC, | ||
144 | * Post_TC_Abort) this request to the silicon. | ||
145 | */ | ||
146 | u32 post_context; | ||
147 | |||
148 | struct scu_task_context *task_context_buffer; | ||
149 | struct scu_task_context tc ____cacheline_aligned; | ||
150 | |||
151 | /* could be larger with sg chaining */ | ||
152 | #define SCU_SGL_SIZE ((SCU_IO_REQUEST_SGE_COUNT + 1) / 2) | ||
153 | struct scu_sgl_element_pair sg_table[SCU_SGL_SIZE] __attribute__ ((aligned(32))); | ||
154 | |||
155 | /** | ||
156 | * This field indicates if this request is a task management request or | ||
157 | * normal IO request. | ||
158 | */ | ||
159 | bool is_task_management_request; | ||
160 | |||
161 | /** | ||
162 | * This field indicates that this request contains an initialized started | ||
163 | * substate machine. | ||
164 | */ | ||
165 | bool has_started_substate_machine; | ||
166 | |||
167 | /** | ||
168 | * This field is a pointer to the stored rx frame data. It is used in STP | ||
169 | * internal requests and SMP response frames. If this field is non-NULL the | ||
170 | * saved frame must be released on IO request completion. | ||
171 | * | ||
172 | * @todo In the future do we want to keep a list of RX frame buffers? | ||
173 | */ | ||
174 | u32 saved_rx_frame_index; | ||
175 | |||
176 | /** | ||
177 | * This field specifies the data necessary to manage the sub-state | ||
178 | * machine executed while in the SCI_BASE_REQUEST_STATE_STARTED state. | ||
179 | */ | ||
180 | struct sci_base_state_machine started_substate_machine; | ||
181 | |||
182 | /** | ||
183 | * This field specifies the current state handlers in place for this | ||
184 | * IO Request object. This field is updated each time the request | ||
185 | * changes state. | ||
186 | */ | ||
187 | const struct scic_sds_io_request_state_handler *state_handlers; | ||
188 | |||
189 | /** | ||
190 | * This field in the recorded device sequence for the io request. This is | ||
191 | * recorded during the build operation and is compared in the start | ||
192 | * operation. If the sequence is different then there was a change of | ||
193 | * devices from the build to start operations. | ||
194 | */ | ||
195 | u8 device_sequence; | ||
196 | |||
197 | union { | ||
198 | struct { | ||
199 | union { | ||
200 | struct ssp_cmd_iu cmd; | ||
201 | struct ssp_task_iu tmf; | ||
202 | }; | ||
203 | union { | ||
204 | struct ssp_response_iu rsp; | ||
205 | u8 rsp_buf[SSP_RESP_IU_MAX_SIZE]; | ||
206 | }; | ||
207 | } ssp; | ||
208 | |||
209 | struct { | ||
210 | struct smp_req cmd; | ||
211 | struct smp_resp rsp; | ||
212 | } smp; | ||
213 | |||
214 | struct { | ||
215 | struct scic_sds_stp_request req; | ||
216 | struct host_to_dev_fis cmd; | ||
217 | struct dev_to_host_fis rsp; | ||
218 | } stp; | ||
219 | }; | ||
220 | |||
221 | }; | ||
222 | |||
223 | static inline struct scic_sds_request *to_sci_req(struct scic_sds_stp_request *stp_req) | ||
224 | { | ||
225 | struct scic_sds_request *sci_req; | ||
226 | |||
227 | sci_req = container_of(stp_req, typeof(*sci_req), stp.req); | ||
228 | return sci_req; | ||
229 | } | ||
230 | |||
85 | struct isci_request { | 231 | struct isci_request { |
86 | enum isci_request_status status; | 232 | enum isci_request_status status; |
87 | enum task_type ttype; | 233 | enum task_type ttype; |
@@ -126,6 +272,273 @@ static inline struct isci_request *sci_req_to_ireq(struct scic_sds_request *sci_ | |||
126 | } | 272 | } |
127 | 273 | ||
128 | /** | 274 | /** |
275 | * enum sci_base_request_states - This enumeration depicts all the states for | ||
276 | * the common request state machine. | ||
277 | * | ||
278 | * | ||
279 | */ | ||
280 | enum sci_base_request_states { | ||
281 | /** | ||
282 | * Simply the initial state for the base request state machine. | ||
283 | */ | ||
284 | SCI_BASE_REQUEST_STATE_INITIAL, | ||
285 | |||
286 | /** | ||
287 | * This state indicates that the request has been constructed. This state | ||
288 | * is entered from the INITIAL state. | ||
289 | */ | ||
290 | SCI_BASE_REQUEST_STATE_CONSTRUCTED, | ||
291 | |||
292 | /** | ||
293 | * This state indicates that the request has been started. This state is | ||
294 | * entered from the CONSTRUCTED state. | ||
295 | */ | ||
296 | SCI_BASE_REQUEST_STATE_STARTED, | ||
297 | |||
298 | /** | ||
299 | * This state indicates that the request has completed. | ||
300 | * This state is entered from the STARTED state. This state is entered from | ||
301 | * the ABORTING state. | ||
302 | */ | ||
303 | SCI_BASE_REQUEST_STATE_COMPLETED, | ||
304 | |||
305 | /** | ||
306 | * This state indicates that the request is in the process of being | ||
307 | * terminated/aborted. | ||
308 | * This state is entered from the CONSTRUCTED state. | ||
309 | * This state is entered from the STARTED state. | ||
310 | */ | ||
311 | SCI_BASE_REQUEST_STATE_ABORTING, | ||
312 | |||
313 | /** | ||
314 | * Simply the final state for the base request state machine. | ||
315 | */ | ||
316 | SCI_BASE_REQUEST_STATE_FINAL, | ||
317 | }; | ||
318 | |||
319 | typedef enum sci_status (*scic_sds_io_request_handler_t) | ||
320 | (struct scic_sds_request *request); | ||
321 | typedef enum sci_status (*scic_sds_io_request_frame_handler_t) | ||
322 | (struct scic_sds_request *req, u32 frame); | ||
323 | typedef enum sci_status (*scic_sds_io_request_event_handler_t) | ||
324 | (struct scic_sds_request *req, u32 event); | ||
325 | typedef enum sci_status (*scic_sds_io_request_task_completion_handler_t) | ||
326 | (struct scic_sds_request *req, u32 completion_code); | ||
327 | |||
328 | /** | ||
329 | * struct scic_sds_io_request_state_handler - This is the SDS core definition | ||
330 | * of the state handlers. | ||
331 | * | ||
332 | * | ||
333 | */ | ||
334 | struct scic_sds_io_request_state_handler { | ||
335 | /** | ||
336 | * The start_handler specifies the method invoked when a user attempts to | ||
337 | * start a request. | ||
338 | */ | ||
339 | scic_sds_io_request_handler_t start_handler; | ||
340 | |||
341 | /** | ||
342 | * The abort_handler specifies the method invoked when a user attempts to | ||
343 | * abort a request. | ||
344 | */ | ||
345 | scic_sds_io_request_handler_t abort_handler; | ||
346 | |||
347 | /** | ||
348 | * The complete_handler specifies the method invoked when a user attempts to | ||
349 | * complete a request. | ||
350 | */ | ||
351 | scic_sds_io_request_handler_t complete_handler; | ||
352 | |||
353 | scic_sds_io_request_task_completion_handler_t tc_completion_handler; | ||
354 | scic_sds_io_request_event_handler_t event_handler; | ||
355 | scic_sds_io_request_frame_handler_t frame_handler; | ||
356 | |||
357 | }; | ||
358 | |||
359 | extern const struct sci_base_state scic_sds_io_request_started_task_mgmt_substate_table[]; | ||
360 | |||
361 | /** | ||
362 | * scic_sds_request_get_controller() - | ||
363 | * | ||
364 | * This macro will return the controller for this io request object | ||
365 | */ | ||
366 | #define scic_sds_request_get_controller(sci_req) \ | ||
367 | ((sci_req)->owning_controller) | ||
368 | |||
369 | /** | ||
370 | * scic_sds_request_get_device() - | ||
371 | * | ||
372 | * This macro will return the device for this io request object | ||
373 | */ | ||
374 | #define scic_sds_request_get_device(sci_req) \ | ||
375 | ((sci_req)->target_device) | ||
376 | |||
377 | /** | ||
378 | * scic_sds_request_get_port() - | ||
379 | * | ||
380 | * This macro will return the port for this io request object | ||
381 | */ | ||
382 | #define scic_sds_request_get_port(sci_req) \ | ||
383 | scic_sds_remote_device_get_port(scic_sds_request_get_device(sci_req)) | ||
384 | |||
385 | /** | ||
386 | * scic_sds_request_get_post_context() - | ||
387 | * | ||
388 | * This macro returns the constructed post context result for the io request. | ||
389 | */ | ||
390 | #define scic_sds_request_get_post_context(sci_req) \ | ||
391 | ((sci_req)->post_context) | ||
392 | |||
393 | /** | ||
394 | * scic_sds_request_get_task_context() - | ||
395 | * | ||
396 | * This is a helper macro to return the os handle for this request object. | ||
397 | */ | ||
398 | #define scic_sds_request_get_task_context(request) \ | ||
399 | ((request)->task_context_buffer) | ||
400 | |||
401 | /** | ||
402 | * scic_sds_request_set_status() - | ||
403 | * | ||
404 | * This macro will set the scu hardware status and sci request completion | ||
405 | * status for an io request. | ||
406 | */ | ||
407 | #define scic_sds_request_set_status(request, scu_status_code, sci_status_code) \ | ||
408 | { \ | ||
409 | (request)->scu_status = (scu_status_code); \ | ||
410 | (request)->sci_status = (sci_status_code); \ | ||
411 | } | ||
412 | |||
413 | #define scic_sds_request_complete(a_request) \ | ||
414 | ((a_request)->state_handlers->complete_handler(a_request)) | ||
415 | |||
416 | |||
417 | extern enum sci_status | ||
418 | scic_sds_io_request_tc_completion(struct scic_sds_request *request, u32 completion_code); | ||
419 | |||
420 | /** | ||
421 | * SCU_SGL_ZERO() - | ||
422 | * | ||
423 | * This macro zeros the hardware SGL element data | ||
424 | */ | ||
425 | #define SCU_SGL_ZERO(scu_sge) \ | ||
426 | { \ | ||
427 | (scu_sge).length = 0; \ | ||
428 | (scu_sge).address_lower = 0; \ | ||
429 | (scu_sge).address_upper = 0; \ | ||
430 | (scu_sge).address_modifier = 0; \ | ||
431 | } | ||
432 | |||
433 | /** | ||
434 | * SCU_SGL_COPY() - | ||
435 | * | ||
436 | * This macro copys the SGL Element data from the host os to the hardware SGL | ||
437 | * elment data | ||
438 | */ | ||
439 | #define SCU_SGL_COPY(scu_sge, os_sge) \ | ||
440 | { \ | ||
441 | (scu_sge).length = sg_dma_len(sg); \ | ||
442 | (scu_sge).address_upper = \ | ||
443 | upper_32_bits(sg_dma_address(sg)); \ | ||
444 | (scu_sge).address_lower = \ | ||
445 | lower_32_bits(sg_dma_address(sg)); \ | ||
446 | (scu_sge).address_modifier = 0; \ | ||
447 | } | ||
448 | |||
449 | void scic_sds_request_build_sgl(struct scic_sds_request *sci_req); | ||
450 | void scic_sds_stp_request_assign_buffers(struct scic_sds_request *sci_req); | ||
451 | void scic_sds_smp_request_assign_buffers(struct scic_sds_request *sci_req); | ||
452 | enum sci_status scic_sds_request_start(struct scic_sds_request *sci_req); | ||
453 | enum sci_status scic_sds_io_request_terminate(struct scic_sds_request *sci_req); | ||
454 | void scic_sds_io_request_copy_response(struct scic_sds_request *sci_req); | ||
455 | enum sci_status scic_sds_io_request_event_handler(struct scic_sds_request *sci_req, | ||
456 | u32 event_code); | ||
457 | enum sci_status scic_sds_io_request_frame_handler(struct scic_sds_request *sci_req, | ||
458 | u32 frame_index); | ||
459 | enum sci_status scic_sds_task_request_terminate(struct scic_sds_request *sci_req); | ||
460 | enum sci_status scic_sds_request_started_state_abort_handler(struct scic_sds_request *sci_req); | ||
461 | |||
462 | /** | ||
463 | * enum _scic_sds_io_request_started_task_mgmt_substates - This enumeration | ||
464 | * depicts all of the substates for a task management request to be | ||
465 | * performed in the STARTED super-state. | ||
466 | * | ||
467 | * | ||
468 | */ | ||
469 | enum scic_sds_raw_request_started_task_mgmt_substates { | ||
470 | /** | ||
471 | * The AWAIT_TC_COMPLETION sub-state indicates that the started raw | ||
472 | * task management request is waiting for the transmission of the | ||
473 | * initial frame (i.e. command, task, etc.). | ||
474 | */ | ||
475 | SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_COMPLETION, | ||
476 | |||
477 | /** | ||
478 | * This sub-state indicates that the started task management request | ||
479 | * is waiting for the reception of an unsolicited frame | ||
480 | * (i.e. response IU). | ||
481 | */ | ||
482 | SCIC_SDS_IO_REQUEST_STARTED_TASK_MGMT_SUBSTATE_AWAIT_TC_RESPONSE, | ||
483 | }; | ||
484 | |||
485 | |||
486 | /** | ||
487 | * enum _scic_sds_smp_request_started_substates - This enumeration depicts all | ||
488 | * of the substates for a SMP request to be performed in the STARTED | ||
489 | * super-state. | ||
490 | * | ||
491 | * | ||
492 | */ | ||
493 | enum scic_sds_smp_request_started_substates { | ||
494 | /** | ||
495 | * This sub-state indicates that the started task management request | ||
496 | * is waiting for the reception of an unsolicited frame | ||
497 | * (i.e. response IU). | ||
498 | */ | ||
499 | SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_RESPONSE, | ||
500 | |||
501 | /** | ||
502 | * The AWAIT_TC_COMPLETION sub-state indicates that the started SMP request is | ||
503 | * waiting for the transmission of the initial frame (i.e. command, task, etc.). | ||
504 | */ | ||
505 | SCIC_SDS_SMP_REQUEST_STARTED_SUBSTATE_AWAIT_TC_COMPLETION, | ||
506 | }; | ||
507 | |||
508 | |||
509 | |||
510 | /* XXX open code in caller */ | ||
511 | static inline void *scic_request_get_virt_addr(struct scic_sds_request *sci_req, | ||
512 | dma_addr_t phys_addr) | ||
513 | { | ||
514 | struct isci_request *ireq = sci_req_to_ireq(sci_req); | ||
515 | dma_addr_t offset; | ||
516 | |||
517 | BUG_ON(phys_addr < ireq->request_daddr); | ||
518 | |||
519 | offset = phys_addr - ireq->request_daddr; | ||
520 | |||
521 | BUG_ON(offset >= sizeof(*ireq)); | ||
522 | |||
523 | return (char *)ireq + offset; | ||
524 | } | ||
525 | |||
526 | /* XXX open code in caller */ | ||
527 | static inline dma_addr_t scic_io_request_get_dma_addr(struct scic_sds_request *sci_req, | ||
528 | void *virt_addr) | ||
529 | { | ||
530 | struct isci_request *ireq = sci_req_to_ireq(sci_req); | ||
531 | |||
532 | char *requested_addr = (char *)virt_addr; | ||
533 | char *base_addr = (char *)ireq; | ||
534 | |||
535 | BUG_ON(requested_addr < base_addr); | ||
536 | BUG_ON((requested_addr - base_addr) >= sizeof(*ireq)); | ||
537 | |||
538 | return ireq->request_daddr + (requested_addr - base_addr); | ||
539 | } | ||
540 | |||
541 | /** | ||
129 | * This function gets the status of the request object. | 542 | * This function gets the status of the request object. |
130 | * @request: This parameter points to the isci_request object | 543 | * @request: This parameter points to the isci_request object |
131 | * | 544 | * |
@@ -337,12 +750,6 @@ static inline void isci_request_unmap_sgl( | |||
337 | } | 750 | } |
338 | } | 751 | } |
339 | 752 | ||
340 | |||
341 | void isci_request_io_request_complete( | ||
342 | struct isci_host *isci_host, | ||
343 | struct isci_request *request, | ||
344 | enum sci_io_status completion_status); | ||
345 | |||
346 | /** | 753 | /** |
347 | * isci_request_io_request_get_next_sge() - This function is called by the sci | 754 | * isci_request_io_request_get_next_sge() - This function is called by the sci |
348 | * core to retrieve the next sge for a given request. | 755 | * core to retrieve the next sge for a given request. |
@@ -385,13 +792,16 @@ static inline void *isci_request_io_request_get_next_sge( | |||
385 | return ret; | 792 | return ret; |
386 | } | 793 | } |
387 | 794 | ||
388 | 795 | void isci_terminate_pending_requests(struct isci_host *isci_host, | |
389 | void isci_terminate_pending_requests( | 796 | struct isci_remote_device *isci_device, |
390 | struct isci_host *isci_host, | 797 | enum isci_request_status new_request_state); |
391 | struct isci_remote_device *isci_device, | 798 | enum sci_status scic_task_request_construct(struct scic_sds_controller *scic, |
392 | enum isci_request_status new_request_state); | 799 | struct scic_sds_remote_device *sci_dev, |
393 | 800 | u16 io_tag, | |
394 | 801 | struct scic_sds_request *sci_req); | |
395 | 802 | enum sci_status scic_task_request_construct_ssp(struct scic_sds_request *sci_req); | |
396 | 803 | enum sci_status scic_task_request_construct_sata(struct scic_sds_request *sci_req); | |
804 | enum sci_status scic_io_request_construct_smp(struct scic_sds_request *sci_req); | ||
805 | void scic_stp_io_request_set_ncq_tag(struct scic_sds_request *sci_req, u16 ncq_tag); | ||
806 | void scic_sds_smp_request_copy_response(struct scic_sds_request *sci_req); | ||
397 | #endif /* !defined(_ISCI_REQUEST_H_) */ | 807 | #endif /* !defined(_ISCI_REQUEST_H_) */ |
diff --git a/drivers/scsi/isci/sata.c b/drivers/scsi/isci/sata.c index 08dabf08f7d7..b9b9271d4736 100644 --- a/drivers/scsi/isci/sata.c +++ b/drivers/scsi/isci/sata.c | |||
@@ -56,8 +56,6 @@ | |||
56 | #include <scsi/sas.h> | 56 | #include <scsi/sas.h> |
57 | #include "isci.h" | 57 | #include "isci.h" |
58 | #include "remote_device.h" | 58 | #include "remote_device.h" |
59 | #include "scic_io_request.h" | ||
60 | #include "scic_task_request.h" | ||
61 | #include "task.h" | 59 | #include "task.h" |
62 | #include "request.h" | 60 | #include "request.h" |
63 | #include "sata.h" | 61 | #include "sata.h" |
diff --git a/drivers/scsi/isci/core/scic_sds_smp_request.c b/drivers/scsi/isci/smp_request.c index 6a2b65b9cf0f..d4750a761c58 100644 --- a/drivers/scsi/isci/core/scic_sds_smp_request.c +++ b/drivers/scsi/isci/smp_request.c | |||
@@ -56,9 +56,7 @@ | |||
56 | #include <scsi/sas.h> | 56 | #include <scsi/sas.h> |
57 | #include "state_machine.h" | 57 | #include "state_machine.h" |
58 | #include "remote_device.h" | 58 | #include "remote_device.h" |
59 | #include "scic_sds_request.h" | 59 | #include "request.h" |
60 | #include "scic_sds_smp_request.h" | ||
61 | #include "sci_util.h" | ||
62 | #include "scu_completion_codes.h" | 60 | #include "scu_completion_codes.h" |
63 | #include "scu_task_context.h" | 61 | #include "scu_task_context.h" |
64 | #include "host.h" | 62 | #include "host.h" |
diff --git a/drivers/scsi/isci/core/scic_sds_ssp_request.c b/drivers/scsi/isci/ssp_request.c index 3fdf68be7a4d..4b6317aeef7d 100644 --- a/drivers/scsi/isci/core/scic_sds_ssp_request.c +++ b/drivers/scsi/isci/ssp_request.c | |||
@@ -54,10 +54,10 @@ | |||
54 | */ | 54 | */ |
55 | 55 | ||
56 | #include "host.h" | 56 | #include "host.h" |
57 | #include "request.h" | ||
57 | #include "state_machine.h" | 58 | #include "state_machine.h" |
58 | #include "scic_sds_request.h" | ||
59 | #include "scu_completion_codes.h" | ||
60 | #include "scu_task_context.h" | 59 | #include "scu_task_context.h" |
60 | #include "scu_completion_codes.h" | ||
61 | 61 | ||
62 | /** | 62 | /** |
63 | * This method processes the completions transport layer (TL) status to | 63 | * This method processes the completions transport layer (TL) status to |
diff --git a/drivers/scsi/isci/core/scic_sds_stp_request.c b/drivers/scsi/isci/stp_request.c index 308f486514e9..298086afa5aa 100644 --- a/drivers/scsi/isci/core/scic_sds_stp_request.c +++ b/drivers/scsi/isci/stp_request.c | |||
@@ -56,13 +56,9 @@ | |||
56 | #include <scsi/sas.h> | 56 | #include <scsi/sas.h> |
57 | #include "sas.h" | 57 | #include "sas.h" |
58 | #include "state_machine.h" | 58 | #include "state_machine.h" |
59 | #include "scic_io_request.h" | ||
60 | #include "remote_device.h" | 59 | #include "remote_device.h" |
61 | #include "scic_sds_request.h" | 60 | #include "stp_request.h" |
62 | #include "scic_sds_stp_pio_request.h" | ||
63 | #include "scic_sds_stp_request.h" | ||
64 | #include "unsolicited_frame_control.h" | 61 | #include "unsolicited_frame_control.h" |
65 | #include "sci_util.h" | ||
66 | #include "scu_completion_codes.h" | 62 | #include "scu_completion_codes.h" |
67 | #include "scu_event_codes.h" | 63 | #include "scu_event_codes.h" |
68 | #include "scu_task_context.h" | 64 | #include "scu_task_context.h" |
diff --git a/drivers/scsi/isci/core/scic_sds_stp_request.h b/drivers/scsi/isci/stp_request.h index f5434f12ad06..eb14874ceda3 100644 --- a/drivers/scsi/isci/core/scic_sds_stp_request.h +++ b/drivers/scsi/isci/stp_request.h | |||
@@ -152,27 +152,44 @@ enum scic_sds_stp_request_started_soft_reset_substates { | |||
152 | SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_D2H_RESPONSE_FRAME_SUBSTATE, | 152 | SCIC_SDS_STP_REQUEST_STARTED_SOFT_RESET_AWAIT_D2H_RESPONSE_FRAME_SUBSTATE, |
153 | }; | 153 | }; |
154 | 154 | ||
155 | u32 scic_sds_stp_request_get_object_size(void); | 155 | /* This is the enumeration of the SATA PIO DATA IN started substate machine. */ |
156 | 156 | enum _scic_sds_stp_request_started_pio_substates { | |
157 | enum sci_status scic_sds_stp_pio_request_construct( | 157 | /** |
158 | struct scic_sds_request *scic_io_request, | 158 | * While in this state the IO request object is waiting for the TC completion |
159 | bool copy_rx_frame); | 159 | * notification for the H2D Register FIS |
160 | 160 | */ | |
161 | enum sci_status scic_sds_stp_udma_request_construct( | 161 | SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_H2D_COMPLETION_SUBSTATE, |
162 | struct scic_sds_request *sci_req, | 162 | |
163 | u32 transfer_length, | 163 | /** |
164 | enum dma_data_direction dir); | 164 | * While in this state the IO request object is waiting for either a PIO Setup |
165 | 165 | * FIS or a D2H register FIS. The type of frame received is based on the | |
166 | enum sci_status scic_sds_stp_non_data_request_construct( | 166 | * result of the prior frame and line conditions. |
167 | struct scic_sds_request *sci_req); | 167 | */ |
168 | 168 | SCIC_SDS_STP_REQUEST_STARTED_PIO_AWAIT_FRAME_SUBSTATE, | |
169 | enum sci_status scic_sds_stp_soft_reset_request_construct( | 169 | |
170 | struct scic_sds_request *sci_req); | 170 | /** |
171 | 171 | * While in this state the IO request object is waiting for a DATA frame from | |
172 | enum sci_status scic_sds_stp_ncq_request_construct( | 172 | * the device. |
173 | struct scic_sds_request *sci_req, | 173 | */ |
174 | u32 transfer_length, | 174 | SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_IN_AWAIT_DATA_SUBSTATE, |
175 | enum dma_data_direction dir); | 175 | |
176 | 176 | /** | |
177 | * While in this state the IO request object is waiting to transmit the next data | ||
178 | * frame to the device. | ||
179 | */ | ||
180 | SCIC_SDS_STP_REQUEST_STARTED_PIO_DATA_OUT_TRANSMIT_DATA_SUBSTATE, | ||
181 | }; | ||
177 | 182 | ||
183 | struct scic_sds_request; | ||
184 | |||
185 | enum sci_status scic_sds_stp_pio_request_construct(struct scic_sds_request *sci_req, | ||
186 | bool copy_rx_frame); | ||
187 | enum sci_status scic_sds_stp_udma_request_construct(struct scic_sds_request *sci_req, | ||
188 | u32 transfer_length, | ||
189 | enum dma_data_direction dir); | ||
190 | enum sci_status scic_sds_stp_non_data_request_construct(struct scic_sds_request *sci_req); | ||
191 | enum sci_status scic_sds_stp_soft_reset_request_construct(struct scic_sds_request *sci_req); | ||
192 | enum sci_status scic_sds_stp_ncq_request_construct(struct scic_sds_request *sci_req, | ||
193 | u32 transfer_length, | ||
194 | enum dma_data_direction dir); | ||
178 | #endif /* _SCIC_SDS_STP_REQUEST_T_ */ | 195 | #endif /* _SCIC_SDS_STP_REQUEST_T_ */ |
diff --git a/drivers/scsi/isci/task.c b/drivers/scsi/isci/task.c index 2a8603881929..078e2ee4f4be 100644 --- a/drivers/scsi/isci/task.c +++ b/drivers/scsi/isci/task.c | |||
@@ -56,15 +56,12 @@ | |||
56 | #include <linux/completion.h> | 56 | #include <linux/completion.h> |
57 | #include <linux/irqflags.h> | 57 | #include <linux/irqflags.h> |
58 | #include "sas.h" | 58 | #include "sas.h" |
59 | #include "scic_task_request.h" | ||
60 | #include "scic_io_request.h" | ||
61 | #include "remote_device.h" | 59 | #include "remote_device.h" |
62 | #include "remote_node_context.h" | 60 | #include "remote_node_context.h" |
63 | #include "isci.h" | 61 | #include "isci.h" |
64 | #include "request.h" | 62 | #include "request.h" |
65 | #include "sata.h" | 63 | #include "sata.h" |
66 | #include "task.h" | 64 | #include "task.h" |
67 | #include "scic_sds_request.h" | ||
68 | #include "timers.h" | 65 | #include "timers.h" |
69 | 66 | ||
70 | /** | 67 | /** |
diff --git a/drivers/scsi/isci/unsolicited_frame_control.c b/drivers/scsi/isci/unsolicited_frame_control.c index 8d68dcc52bc1..12e676346386 100644 --- a/drivers/scsi/isci/unsolicited_frame_control.c +++ b/drivers/scsi/isci/unsolicited_frame_control.c | |||
@@ -56,7 +56,6 @@ | |||
56 | #include "host.h" | 56 | #include "host.h" |
57 | #include "unsolicited_frame_control.h" | 57 | #include "unsolicited_frame_control.h" |
58 | #include "registers.h" | 58 | #include "registers.h" |
59 | #include "sci_util.h" | ||
60 | 59 | ||
61 | /** | 60 | /** |
62 | * This method will program the unsolicited frames (UFs) into the UF address | 61 | * This method will program the unsolicited frames (UFs) into the UF address |
@@ -93,10 +92,8 @@ static void scic_sds_unsolicited_frame_control_construct_frames( | |||
93 | for (index = 0; index < unused_uf_header_entries; index++) { | 92 | for (index = 0; index < unused_uf_header_entries; index++) { |
94 | uf = &uf_control->buffers.array[index]; | 93 | uf = &uf_control->buffers.array[index]; |
95 | 94 | ||
96 | sci_cb_make_physical_address( | ||
97 | uf_control->address_table.array[index], 0, 0 | ||
98 | ); | ||
99 | uf->buffer = NULL; | 95 | uf->buffer = NULL; |
96 | uf_control->address_table.array[index] = 0; | ||
100 | uf->header = &uf_control->headers.array[index]; | 97 | uf->header = &uf_control->headers.array[index]; |
101 | uf->state = UNSOLICITED_FRAME_EMPTY; | 98 | uf->state = UNSOLICITED_FRAME_EMPTY; |
102 | } | 99 | } |