aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Jiang <dave.jiang@intel.com>2011-05-04 21:01:22 -0400
committerDan Williams <dan.j.williams@intel.com>2011-07-03 07:04:46 -0400
commit2ec53eb4d5b301e5c9c386da5685894d572772a5 (patch)
tree5ae482456e06c036f61724318019299b3a3ca359
parentaf5ae89350840b9d724fc4fb81d928673bffdd4d (diff)
isci: Fixup of smp request
The struct smp_request data structure has be fixed up for Linux consumption. This probably should go to scsi/sas.h eventually. Signed-off-by: Dave Jiang <dave.jiang@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
-rw-r--r--drivers/scsi/isci/core/intel_sas.h156
-rw-r--r--drivers/scsi/isci/core/scic_sds_request.c41
-rw-r--r--drivers/scsi/isci/core/scic_sds_smp_request.c104
-rw-r--r--drivers/scsi/isci/request.c48
-rw-r--r--drivers/scsi/isci/sas.h107
5 files changed, 196 insertions, 260 deletions
diff --git a/drivers/scsi/isci/core/intel_sas.h b/drivers/scsi/isci/core/intel_sas.h
index 3d4ca12df5ff..d10c3824dbe4 100644
--- a/drivers/scsi/isci/core/intel_sas.h
+++ b/drivers/scsi/isci/core/intel_sas.h
@@ -199,20 +199,6 @@ struct sci_ssp_frame_header {
199}; 199};
200 200
201/** 201/**
202 * struct smp_request_header - This structure defines the contents of an SMP
203 * Request header.
204 *
205 * For specific information on each of these individual fields please reference
206 * the SAS specification.
207 */
208struct smp_request_header {
209 u8 smp_frame_type; /* byte 0 */
210 u8 function; /* byte 1 */
211 u8 allocated_response_length; /* byte 2 */
212 u8 request_length; /* byte 3 */
213};
214
215/**
216 * struct smp_response_header - This structure depicts the contents of the SAS 202 * struct smp_response_header - This structure depicts the contents of the SAS
217 * SMP DISCOVER RESPONSE frame. For specific information on each of these 203 * SMP DISCOVER RESPONSE frame. For specific information on each of these
218 * individual fields please reference the SAS specification Link layer 204 * individual fields please reference the SAS specification Link layer
@@ -227,136 +213,6 @@ struct smp_response_header {
227 u8 response_length; /* byte 3 */ 213 u8 response_length; /* byte 3 */
228}; 214};
229 215
230/**
231 * struct smp_request_general - This structure defines the contents of an SMP
232 * Request that is comprised of the struct smp_request_header and a CRC.
233 *
234 * For specific information on each of these individual fields please reference
235 * the SAS specification.
236 */
237struct smp_request_general {
238 u32 crc; /* bytes 4-7 */
239
240};
241
242/**
243 * struct smp_request_phy_identifier - This structure defines the contents of
244 * an SMP Request that is comprised of the struct smp_request_header and a phy
245 * identifier. Examples: SMP_REQUEST_DISCOVER, SMP_REQUEST_REPORT_PHY_SATA.
246 *
247 * For specific information on each of these individual fields please reference
248 * the SAS specification.
249 */
250struct smp_request_phy_identifier {
251 u32 reserved_byte4_7; /* bytes 4-7 */
252
253 u32 ignore_zone_group:1; /* byte 8 */
254 u32 reserved_byte8:7;
255
256 u32 phy_identifier:8; /* byte 9 */
257 u32 reserved_byte10:8; /* byte 10 */
258 u32 reserved_byte11:8; /* byte 11 */
259
260};
261
262/**
263 * struct smp_request_configure_route_information - This structure defines the
264 * contents of an SMP Configure Route Information request.
265 *
266 * For specific information on each of these individual fields please reference
267 * the SAS specification.
268 */
269struct smp_request_configure_route_information {
270 u32 expected_expander_change_count:16; /* bytes 4-5 */
271 u32 expander_route_index_high:8;
272 u32 expander_route_index:8; /* bytes 6-7 */
273
274 u32 reserved_byte8:8; /* bytes 8 */
275 u32 phy_identifier:8; /* bytes 9 */
276 u32 reserved_byte_10_11:16; /* bytes 10-11 */
277
278 u32 reserved_byte_12_bit_0_6:7;
279 u32 disable_route_entry:1; /* byte 12 */
280 u32 reserved_byte_13_15:24; /* bytes 13-15 */
281
282 u32 routed_sas_address[2]; /* bytes 16-23 */
283 u8 reserved_byte_24_39[16]; /* bytes 24-39 */
284
285};
286
287/**
288 * struct smp_request_phy_control - This structure defines the contents of an
289 * SMP Phy Controler request.
290 *
291 * For specific information on each of these individual fields please reference
292 * the SAS specification.
293 */
294struct smp_request_phy_control {
295 u16 expected_expander_change_count; /* byte 4-5 */
296
297 u16 reserved_byte_6_7; /* byte 6-7 */
298 u8 reserved_byte_8; /* byte 8 */
299
300 u8 phy_identifier; /* byte 9 */
301 u8 phy_operation; /* byte 10 */
302
303 u8 update_partial_pathway_timeout_value:1;
304 u8 reserved_byte_11_bit_1_7:7; /* byte 11 */
305
306 u8 reserved_byte_12_23[12]; /* byte 12-23 */
307
308 u8 attached_device_name[8]; /* byte 24-31 */
309
310 u8 reserved_byte_32_bit_3_0:4; /* byte 32 */
311 u8 programmed_minimum_physical_link_rate:4;
312
313 u8 reserved_byte_33_bit_3_0:4; /* byte 33 */
314 u8 programmed_maximum_physical_link_rate:4;
315
316 u16 reserved_byte_34_35; /* byte 34-35 */
317
318 u8 partial_pathway_timeout_value:4;
319 u8 reserved_byte_36_bit_4_7:4; /* byte 36 */
320
321 u16 reserved_byte_37_38; /* byte 37-38 */
322 u8 reserved_byte_39; /* byte 39 */
323
324};
325
326/**
327 * struct smp_request_vendor_specific - This structure depicts the vendor
328 * specific space for SMP request.
329 *
330 *
331 */
332 #define SMP_REQUEST_VENDOR_SPECIFIC_MAX_LENGTH 1016
333struct smp_request_vendor_specific {
334 u8 request_bytes[SMP_REQUEST_VENDOR_SPECIFIC_MAX_LENGTH];
335};
336
337/**
338 * struct smp_request - This structure simply unionizes the existing request
339 * structures into a common request type.
340 *
341 *
342 */
343struct smp_request {
344 struct smp_request_header header;
345
346 union { /* bytes 4-N */
347 struct smp_request_general report_general;
348 struct smp_request_phy_identifier discover;
349 struct smp_request_general report_manufacturer_information;
350 struct smp_request_phy_identifier report_phy_sata;
351 struct smp_request_phy_control phy_control;
352 struct smp_request_phy_identifier report_phy_error_log;
353 struct smp_request_phy_identifier report_route_information;
354 struct smp_request_configure_route_information configure_route_information;
355 struct smp_request_vendor_specific vendor_specific_request;
356 } request;
357
358};
359
360 216
361/** 217/**
362 * struct smp_response_report_general - This structure depicts the SMP Report 218 * struct smp_response_report_general - This structure depicts the SMP Report
@@ -493,6 +349,7 @@ struct smp_response_report_phy_sata {
493 349
494}; 350};
495 351
352#define SMP_REQUEST_VENDOR_SPECIFIC_MAX_LENGTH 1016
496struct smp_response_vendor_specific { 353struct smp_response_vendor_specific {
497 u8 response_bytes[SMP_REQUEST_VENDOR_SPECIFIC_MAX_LENGTH]; 354 u8 response_bytes[SMP_REQUEST_VENDOR_SPECIFIC_MAX_LENGTH];
498}; 355};
@@ -517,17 +374,6 @@ struct smp_response {
517 374
518}; 375};
519 376
520/* SMP Request Functions */
521#define SMP_FUNCTION_REPORT_GENERAL 0x00
522#define SMP_FUNCTION_REPORT_MANUFACTURER_INFORMATION 0x01
523#define SMP_FUNCTION_DISCOVER 0x10
524#define SMP_FUNCTION_REPORT_PHY_ERROR_LOG 0x11
525#define SMP_FUNCTION_REPORT_PHY_SATA 0x12
526#define SMP_FUNCTION_REPORT_ROUTE_INFORMATION 0X13
527#define SMP_FUNCTION_CONFIGURE_ROUTE_INFORMATION 0X90
528#define SMP_FUNCTION_PHY_CONTROL 0x91
529#define SMP_FUNCTION_PHY_TEST 0x92
530
531#define SMP_FRAME_TYPE_REQUEST 0x40 377#define SMP_FRAME_TYPE_REQUEST 0x40
532#define SMP_FRAME_TYPE_RESPONSE 0x41 378#define SMP_FRAME_TYPE_RESPONSE 0x41
533 379
diff --git a/drivers/scsi/isci/core/scic_sds_request.c b/drivers/scsi/isci/core/scic_sds_request.c
index ef59e019398e..8eb3c7e59ec5 100644
--- a/drivers/scsi/isci/core/scic_sds_request.c
+++ b/drivers/scsi/isci/core/scic_sds_request.c
@@ -1658,38 +1658,47 @@ static void scic_sds_general_request_construct(struct scic_sds_controller *scic,
1658 } 1658 }
1659} 1659}
1660 1660
1661enum sci_status scic_io_request_construct(struct scic_sds_controller *scic, 1661enum sci_status
1662 struct scic_sds_remote_device *sci_dev, 1662scic_io_request_construct(struct scic_sds_controller *scic,
1663 u16 io_tag, 1663 struct scic_sds_remote_device *sci_dev,
1664 void *user_io_request_object, 1664 u16 io_tag,
1665 struct scic_sds_request *sci_req, 1665 void *user_req,
1666 struct scic_sds_request **new_scic_io_request_handle) 1666 struct scic_sds_request *sci_req,
1667 struct scic_sds_request **new_sci_req)
1667{ 1668{
1668 struct domain_device *dev = sci_dev_to_domain(sci_dev); 1669 struct domain_device *dev = sci_dev_to_domain(sci_dev);
1669 enum sci_status status = SCI_SUCCESS; 1670 enum sci_status status = SCI_SUCCESS;
1670 1671
1671 /* Build the common part of the request */ 1672 /* Build the common part of the request */
1672 scic_sds_general_request_construct(scic, sci_dev, io_tag, 1673 scic_sds_general_request_construct(scic,
1673 user_io_request_object, sci_req); 1674 sci_dev,
1675 io_tag,
1676 user_req,
1677 sci_req);
1674 1678
1675 if (sci_dev->rnc.remote_node_index == SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX) 1679 if (sci_dev->rnc.remote_node_index ==
1680 SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX)
1676 return SCI_FAILURE_INVALID_REMOTE_DEVICE; 1681 return SCI_FAILURE_INVALID_REMOTE_DEVICE;
1677 1682
1678 if (dev->dev_type == SAS_END_DEV) { 1683 if (dev->dev_type == SAS_END_DEV)
1679 scic_sds_ssp_io_request_assign_buffers(sci_req); 1684 scic_sds_ssp_io_request_assign_buffers(sci_req);
1680 } else if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) { 1685 else if ((dev->dev_type == SATA_DEV) ||
1686 (dev->tproto & SAS_PROTOCOL_STP)) {
1681 scic_sds_stp_request_assign_buffers(sci_req); 1687 scic_sds_stp_request_assign_buffers(sci_req);
1682 memset(sci_req->command_buffer, 0, sizeof(struct host_to_dev_fis)); 1688 memset(sci_req->command_buffer,
1689 0,
1690 sizeof(struct host_to_dev_fis));
1683 } else if (dev_is_expander(dev)) { 1691 } else if (dev_is_expander(dev)) {
1684 scic_sds_smp_request_assign_buffers(sci_req); 1692 scic_sds_smp_request_assign_buffers(sci_req);
1685 memset(sci_req->command_buffer, 0, sizeof(struct smp_request)); 1693 memset(sci_req->command_buffer, 0, sizeof(struct smp_req));
1686 } else 1694 } else
1687 status = SCI_FAILURE_UNSUPPORTED_PROTOCOL; 1695 status = SCI_FAILURE_UNSUPPORTED_PROTOCOL;
1688 1696
1689 if (status == SCI_SUCCESS) { 1697 if (status == SCI_SUCCESS) {
1690 memset(sci_req->task_context_buffer, 0, 1698 memset(sci_req->task_context_buffer,
1691 SCI_FIELD_OFFSET(struct scu_task_context, sgl_pair_ab)); 1699 0,
1692 *new_scic_io_request_handle = sci_req; 1700 SCI_FIELD_OFFSET(struct scu_task_context, sgl_pair_ab));
1701 *new_sci_req = sci_req;
1693 } 1702 }
1694 1703
1695 return status; 1704 return status;
diff --git a/drivers/scsi/isci/core/scic_sds_smp_request.c b/drivers/scsi/isci/core/scic_sds_smp_request.c
index 2815da288750..7d7bd2e29d8f 100644
--- a/drivers/scsi/isci/core/scic_sds_smp_request.c
+++ b/drivers/scsi/isci/core/scic_sds_smp_request.c
@@ -53,6 +53,7 @@
53 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 53 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54 */ 54 */
55 55
56#include "sas.h"
56#include "intel_sas.h" 57#include "intel_sas.h"
57#include "sci_base_state_machine.h" 58#include "sci_base_state_machine.h"
58#include "scic_controller.h" 59#include "scic_controller.h"
@@ -67,7 +68,7 @@
67 68
68static void scu_smp_request_construct_task_context( 69static void scu_smp_request_construct_task_context(
69 struct scic_sds_request *sci_req, 70 struct scic_sds_request *sci_req,
70 struct smp_request *smp_request); 71 struct smp_req *smp_req);
71 72
72/** 73/**
73 * 74 *
@@ -77,7 +78,7 @@ static void scu_smp_request_construct_task_context(
77u32 scic_sds_smp_request_get_object_size(void) 78u32 scic_sds_smp_request_get_object_size(void)
78{ 79{
79 return sizeof(struct scic_sds_request) 80 return sizeof(struct scic_sds_request)
80 + sizeof(struct smp_request) 81 + sizeof(struct smp_req)
81 + sizeof(struct smp_response) 82 + sizeof(struct smp_response)
82 + sizeof(struct scu_task_context) 83 + sizeof(struct scu_task_context)
83 + SMP_CACHE_BYTES; 84 + SMP_CACHE_BYTES;
@@ -100,7 +101,7 @@ u32 scic_sds_smp_request_get_object_size(void)
100 */ 101 */
101#define scic_sds_smp_request_get_response_buffer(memory) \ 102#define scic_sds_smp_request_get_response_buffer(memory) \
102 (((char *)(scic_sds_smp_request_get_command_buffer(memory))) \ 103 (((char *)(scic_sds_smp_request_get_command_buffer(memory))) \
103 + sizeof(struct smp_request)) 104 + sizeof(struct smp_req))
104 105
105/** 106/**
106 * scic_sds_smp_request_get_task_context_buffer() - 107 * scic_sds_smp_request_get_task_context_buffer() -
@@ -142,21 +143,8 @@ void scic_sds_smp_request_assign_buffers(
142 143
143} 144}
144 145
145/** 146/*
146 * This method is called by the SCI user to build an SMP pass-through IO 147 * This function will fill in the SCU Task Context for a SMP request. The
147 * request.
148 * @scic_smp_request: This parameter specifies the handle to the io request
149 * object to be built.
150 * @passthru_cb: This parameter specifies the pointer to the callback structure
151 * that contains the function pointers
152 *
153 * - The user must have previously called scic_io_request_construct() on the
154 * supplied IO request. Indicate if the controller successfully built the IO
155 * request.
156 */
157
158/**
159 * This method will fill in the SCU Task Context for a SMP request. The
160 * following important settings are utilized: -# task_type == 148 * following important settings are utilized: -# task_type ==
161 * SCU_TASK_TYPE_SMP. This simply indicates that a normal request type 149 * SCU_TASK_TYPE_SMP. This simply indicates that a normal request type
162 * (i.e. non-raw frame) is being utilized to perform task management. -# 150 * (i.e. non-raw frame) is being utilized to perform task management. -#
@@ -166,26 +154,26 @@ void scic_sds_smp_request_assign_buffers(
166 * constructed. 154 * constructed.
167 * 155 *
168 */ 156 */
169static void scu_smp_request_construct_task_context( 157static void
170 struct scic_sds_request *sds_request, 158scu_smp_request_construct_task_context(struct scic_sds_request *sci_req,
171 struct smp_request *smp_request) 159 struct smp_req *smp_req)
172{ 160{
173 dma_addr_t dma_addr; 161 dma_addr_t dma_addr;
174 struct scic_sds_controller *controller; 162 struct scic_sds_controller *scic;
175 struct scic_sds_remote_device *sci_dev; 163 struct scic_sds_remote_device *sci_dev;
176 struct scic_sds_port *target_port; 164 struct scic_sds_port *sci_port;
177 struct scu_task_context *task_context; 165 struct scu_task_context *task_context;
178 166
179 /* byte swap the smp request. */ 167 /* byte swap the smp request. */
180 scic_word_copy_with_swap(sds_request->command_buffer, 168 scic_word_copy_with_swap(sci_req->command_buffer,
181 (u32 *)smp_request, 169 (u32 *)smp_req,
182 sizeof(struct smp_request) / sizeof(u32)); 170 sizeof(struct smp_req) / sizeof(u32));
183 171
184 task_context = scic_sds_request_get_task_context(sds_request); 172 task_context = scic_sds_request_get_task_context(sci_req);
185 173
186 controller = scic_sds_request_get_controller(sds_request); 174 scic = scic_sds_request_get_controller(sci_req);
187 sci_dev = scic_sds_request_get_device(sds_request); 175 sci_dev = scic_sds_request_get_device(sci_req);
188 target_port = scic_sds_request_get_port(sds_request); 176 sci_port = scic_sds_request_get_port(sci_req);
189 177
190 /* 178 /*
191 * Fill in the TC with the its required data 179 * Fill in the TC with the its required data
@@ -195,9 +183,8 @@ static void scu_smp_request_construct_task_context(
195 task_context->initiator_request = 1; 183 task_context->initiator_request = 1;
196 task_context->connection_rate = sci_dev->connection_rate; 184 task_context->connection_rate = sci_dev->connection_rate;
197 task_context->protocol_engine_index = 185 task_context->protocol_engine_index =
198 scic_sds_controller_get_protocol_engine_group(controller); 186 scic_sds_controller_get_protocol_engine_group(scic);
199 task_context->logical_port_index = 187 task_context->logical_port_index = scic_sds_port_get_index(sci_port);
200 scic_sds_port_get_index(target_port);
201 task_context->protocol_type = SCU_TASK_CONTEXT_PROTOCOL_SMP; 188 task_context->protocol_type = SCU_TASK_CONTEXT_PROTOCOL_SMP;
202 task_context->abort = 0; 189 task_context->abort = 0;
203 task_context->valid = SCU_TASK_CONTEXT_VALID; 190 task_context->valid = SCU_TASK_CONTEXT_VALID;
@@ -220,8 +207,7 @@ static void scu_smp_request_construct_task_context(
220 task_context->address_modifier = 0; 207 task_context->address_modifier = 0;
221 208
222 /* 10h */ 209 /* 10h */
223 task_context->ssp_command_iu_length = 210 task_context->ssp_command_iu_length = smp_req->req_len;
224 smp_request->header.request_length;
225 211
226 /* 14h */ 212 /* 14h */
227 task_context->transfer_length_bytes = 0; 213 task_context->transfer_length_bytes = 0;
@@ -231,7 +217,7 @@ static void scu_smp_request_construct_task_context(
231 * since commandIU has been build by framework at this point, we just 217 * since commandIU has been build by framework at this point, we just
232 * copy the frist DWord from command IU to this location. */ 218 * copy the frist DWord from command IU to this location. */
233 memcpy((void *)(&task_context->type.smp), 219 memcpy((void *)(&task_context->type.smp),
234 sds_request->command_buffer, 220 sci_req->command_buffer,
235 sizeof(u32)); 221 sizeof(u32));
236 222
237 /* 223 /*
@@ -241,19 +227,18 @@ static void scu_smp_request_construct_task_context(
241 */ 227 */
242 task_context->task_phase = 0; 228 task_context->task_phase = 0;
243 229
244 if (sds_request->was_tag_assigned_by_user) { 230 if (sci_req->was_tag_assigned_by_user) {
245 /* 231 /*
246 * Build the task context now since we have already read 232 * Build the task context now since we have already read
247 * the data 233 * the data
248 */ 234 */
249 sds_request->post_context = 235 sci_req->post_context =
250 (SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC | 236 (SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC |
251 (scic_sds_controller_get_protocol_engine_group( 237 (scic_sds_controller_get_protocol_engine_group(scic) <<
252 controller) <<
253 SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT) | 238 SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT) |
254 (scic_sds_port_get_index(target_port) << 239 (scic_sds_port_get_index(sci_port) <<
255 SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT) | 240 SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT) |
256 scic_sds_io_tag_get_index(sds_request->io_tag)); 241 scic_sds_io_tag_get_index(sci_req->io_tag));
257 } else { 242 } else {
258 /* 243 /*
259 * Build the task context now since we have already read 244 * Build the task context now since we have already read
@@ -261,12 +246,11 @@ static void scu_smp_request_construct_task_context(
261 * I/O tag index is not assigned because we have to wait 246 * I/O tag index is not assigned because we have to wait
262 * until we get a TCi. 247 * until we get a TCi.
263 */ 248 */
264 sds_request->post_context = 249 sci_req->post_context =
265 (SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC | 250 (SCU_CONTEXT_COMMAND_REQUEST_TYPE_POST_TC |
266 (scic_sds_controller_get_protocol_engine_group( 251 (scic_sds_controller_get_protocol_engine_group(scic) <<
267 controller) <<
268 SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT) | 252 SCU_CONTEXT_COMMAND_PROTOCOL_ENGINE_GROUP_SHIFT) |
269 (scic_sds_port_get_index(target_port) << 253 (scic_sds_port_get_index(sci_port) <<
270 SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT)); 254 SCU_CONTEXT_COMMAND_LOGICAL_PORT_SHIFT));
271 } 255 }
272 256
@@ -274,9 +258,9 @@ static void scu_smp_request_construct_task_context(
274 * Copy the physical address for the command buffer to the SCU Task 258 * Copy the physical address for the command buffer to the SCU Task
275 * Context command buffer should not contain command header. 259 * Context command buffer should not contain command header.
276 */ 260 */
277 dma_addr = scic_io_request_get_dma_addr(sds_request, 261 dma_addr = scic_io_request_get_dma_addr(sci_req,
278 (char *) 262 (char *)
279 (sds_request->command_buffer) + 263 (sci_req->command_buffer) +
280 sizeof(u32)); 264 sizeof(u32));
281 265
282 task_context->command_iu_upper = upper_32_bits(dma_addr); 266 task_context->command_iu_upper = upper_32_bits(dma_addr);
@@ -577,7 +561,7 @@ static const struct sci_base_state scic_sds_smp_request_started_substate_table[]
577 */ 561 */
578enum sci_status scic_io_request_construct_smp(struct scic_sds_request *sci_req) 562enum sci_status scic_io_request_construct_smp(struct scic_sds_request *sci_req)
579{ 563{
580 struct smp_request *smp_req = kmalloc(sizeof(*smp_req), GFP_KERNEL); 564 struct smp_req *smp_req = kmalloc(sizeof(*smp_req), GFP_KERNEL);
581 565
582 if (!smp_req) 566 if (!smp_req)
583 return SCI_FAILURE_INSUFFICIENT_RESOURCES; 567 return SCI_FAILURE_INSUFFICIENT_RESOURCES;
@@ -600,18 +584,18 @@ enum sci_status scic_io_request_construct_smp(struct scic_sds_request *sci_req)
600 * Look at the SMP requests' header fields; for certain SAS 1.x SMP 584 * Look at the SMP requests' header fields; for certain SAS 1.x SMP
601 * functions under SAS 2.0, a zero request length really indicates 585 * functions under SAS 2.0, a zero request length really indicates
602 * a non-zero default length. */ 586 * a non-zero default length. */
603 if (smp_req->header.request_length == 0) { 587 if (smp_req->req_len == 0) {
604 switch (smp_req->header.function) { 588 switch (smp_req->func) {
605 case SMP_FUNCTION_DISCOVER: 589 case SMP_DISCOVER:
606 case SMP_FUNCTION_REPORT_PHY_ERROR_LOG: 590 case SMP_REPORT_PHY_ERR_LOG:
607 case SMP_FUNCTION_REPORT_PHY_SATA: 591 case SMP_REPORT_PHY_SATA:
608 case SMP_FUNCTION_REPORT_ROUTE_INFORMATION: 592 case SMP_REPORT_ROUTE_INFO:
609 smp_req->header.request_length = 2; 593 smp_req->req_len = 2;
610 break; 594 break;
611 case SMP_FUNCTION_CONFIGURE_ROUTE_INFORMATION: 595 case SMP_CONF_ROUTE_INFO:
612 case SMP_FUNCTION_PHY_CONTROL: 596 case SMP_PHY_CONTROL:
613 case SMP_FUNCTION_PHY_TEST: 597 case SMP_PHY_TEST_FUNCTION:
614 smp_req->header.request_length = 9; 598 smp_req->req_len = 9;
615 break; 599 break;
616 /* Default - zero is a valid default for 2.0. */ 600 /* Default - zero is a valid default for 2.0. */
617 } 601 }
diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c
index 501df3ca4280..36adc1589efa 100644
--- a/drivers/scsi/isci/request.c
+++ b/drivers/scsi/isci/request.c
@@ -61,7 +61,8 @@
61#include "request.h" 61#include "request.h"
62#include "sata.h" 62#include "sata.h"
63#include "scu_completion_codes.h" 63#include "scu_completion_codes.h"
64#include "core/scic_sds_request.h" 64#include "scic_sds_request.h"
65#include "sas.h"
65 66
66static enum sci_status isci_request_ssp_request_construct( 67static enum sci_status isci_request_ssp_request_construct(
67 struct isci_request *request) 68 struct isci_request *request)
@@ -113,47 +114,37 @@ static enum sci_status isci_request_stp_request_construct(
113 return status; 114 return status;
114} 115}
115 116
116/** 117/*
117 * isci_smp_request_build() - This function builds the smp request object. 118 * isci_smp_request_build() - This function builds the smp request.
118 * @isci_host: This parameter specifies the ISCI host object 119 * @ireq: This parameter points to the isci_request allocated in the
119 * @request: This parameter points to the isci_request object allocated in the
120 * request construct function. 120 * request construct function.
121 * @sci_device: This parameter is the handle for the sci core's remote device
122 * object that is the destination for this request.
123 * 121 *
124 * SCI_SUCCESS on successfull completion, or specific failure code. 122 * SCI_SUCCESS on successfull completion, or specific failure code.
125 */ 123 */
126static enum sci_status isci_smp_request_build( 124static enum sci_status isci_smp_request_build(struct isci_request *ireq)
127 struct isci_request *request)
128{ 125{
129 enum sci_status status = SCI_FAILURE; 126 enum sci_status status = SCI_FAILURE;
130 struct sas_task *task = isci_request_access_task(request); 127 struct sas_task *task = isci_request_access_task(ireq);
128 struct scic_sds_request *sci_req = ireq->sci_request_handle;
129 void *cmd_iu = sci_req->command_buffer;
131 130
132 void *command_iu_address = 131 dev_dbg(&ireq->isci_host->pdev->dev,
133 scic_io_request_get_command_iu_address( 132 "%s: request = %p\n", __func__, ireq);
134 request->sci_request_handle
135 );
136 133
137 dev_dbg(&request->isci_host->pdev->dev, 134 dev_dbg(&ireq->isci_host->pdev->dev,
138 "%s: request = %p\n",
139 __func__,
140 request);
141 dev_dbg(&request->isci_host->pdev->dev,
142 "%s: smp_req len = %d\n", 135 "%s: smp_req len = %d\n",
143 __func__, 136 __func__,
144 task->smp_task.smp_req.length); 137 task->smp_task.smp_req.length);
145 138
146 /* copy the smp_command to the address; */ 139 /* copy the smp_command to the address; */
147 sg_copy_to_buffer(&task->smp_task.smp_req, 1, 140 sg_copy_to_buffer(&task->smp_task.smp_req, 1,
148 (char *)command_iu_address, 141 (char *)cmd_iu,
149 sizeof(struct smp_request) 142 sizeof(struct smp_req));
150 );
151 143
152 status = scic_io_request_construct_smp(request->sci_request_handle); 144 status = scic_io_request_construct_smp(sci_req);
153 if (status != SCI_SUCCESS) 145 if (status != SCI_SUCCESS)
154 dev_warn(&request->isci_host->pdev->dev, 146 dev_warn(&ireq->isci_host->pdev->dev,
155 "%s: scic_io_request_construct_smp failed with " 147 "%s: failed with status = %d\n",
156 "status = %d\n",
157 __func__, 148 __func__,
158 status); 149 status);
159 150
@@ -1073,9 +1064,8 @@ void isci_request_io_request_complete(
1073 sg_copy_from_buffer( 1064 sg_copy_from_buffer(
1074 &task->smp_task.smp_resp, 1, 1065 &task->smp_task.smp_resp, 1,
1075 command_iu_address 1066 command_iu_address
1076 + sizeof(struct smp_request), 1067 + sizeof(struct smp_req),
1077 sizeof(struct smp_resp) 1068 sizeof(struct smp_resp));
1078 );
1079 } else if (completion_status 1069 } else if (completion_status
1080 == SCI_IO_SUCCESS_IO_DONE_EARLY) { 1070 == SCI_IO_SUCCESS_IO_DONE_EARLY) {
1081 1071
diff --git a/drivers/scsi/isci/sas.h b/drivers/scsi/isci/sas.h
index 1a1e9bc125c3..f5d7e6a51070 100644
--- a/drivers/scsi/isci/sas.h
+++ b/drivers/scsi/isci/sas.h
@@ -55,6 +55,9 @@
55 55
56#ifndef _SCI_SAS_H_ 56#ifndef _SCI_SAS_H_
57#define _SCI_SAS_H_ 57#define _SCI_SAS_H_
58
59#include <linux/kernel.h>
60
58/* 61/*
59 * SATA FIS Types These constants depict the various SATA FIS types devined in 62 * SATA FIS Types These constants depict the various SATA FIS types devined in
60 * the serial ATA specification. 63 * the serial ATA specification.
@@ -106,4 +109,108 @@ struct ssp_task_iu {
106 u8 _r_c[12]; 109 u8 _r_c[12];
107} __packed; 110} __packed;
108 111
112
113/*
114 * struct smp_req_phy_id - This structure defines the contents of
115 * an SMP Request that is comprised of the struct smp_request_header and a
116 * phy identifier.
117 * Examples: SMP_REQUEST_DISCOVER, SMP_REQUEST_REPORT_PHY_SATA.
118 *
119 * For specific information on each of these individual fields please reference
120 * the SAS specification.
121 */
122struct smp_req_phy_id {
123 u8 _r_a[4]; /* bytes 4-7 */
124
125 u8 ign_zone_grp:1; /* byte 8 */
126 u8 _r_b:7;
127
128 u8 phy_id; /* byte 9 */
129 u8 _r_c; /* byte 10 */
130 u8 _r_d; /* byte 11 */
131} __packed;
132
133/*
134 * struct smp_req_config_route_info - This structure defines the
135 * contents of an SMP Configure Route Information request.
136 *
137 * For specific information on each of these individual fields please reference
138 * the SAS specification.
139 */
140struct smp_req_conf_rtinfo {
141 u16 exp_change_cnt; /* bytes 4-5 */
142 u8 exp_rt_idx_hi; /* byte 6 */
143 u8 exp_rt_idx; /* byte 7 */
144
145 u8 _r_a; /* byte 8 */
146 u8 phy_id; /* byte 9 */
147 u16 _r_b; /* bytes 10-11 */
148
149 u8 _r_c:7; /* byte 12 */
150 u8 dis_rt_entry:1;
151 u8 _r_d[3]; /* bytes 13-15 */
152
153 u8 rt_sas_addr[8]; /* bytes 16-23 */
154 u8 _r_e[16]; /* bytes 24-39 */
155} __packed;
156
157/*
158 * struct smp_req_phycntl - This structure defines the contents of an
159 * SMP Phy Controller request.
160 *
161 * For specific information on each of these individual fields please reference
162 * the SAS specification.
163 */
164struct smp_req_phycntl {
165 u16 exp_change_cnt; /* byte 4-5 */
166
167 u8 _r_a[3]; /* bytes 6-8 */
168
169 u8 phy_id; /* byte 9 */
170 u8 phy_op; /* byte 10 */
171
172 u8 upd_pathway:1; /* byte 11 */
173 u8 _r_b:7;
174
175 u8 _r_c[12]; /* byte 12-23 */
176
177 u8 att_dev_name[8]; /* byte 24-31 */
178
179 u8 _r_d:4; /* byte 32 */
180 u8 min_linkrate:4;
181
182 u8 _r_e:4; /* byte 33 */
183 u8 max_linkrate:4;
184
185 u8 _r_f[2]; /* byte 34-35 */
186
187 u8 pathway:4; /* byte 36 */
188 u8 _r_g:4;
189
190 u8 _r_h[3]; /* bytes 37-39 */
191} __packed;
192
193#define SMP_REQ_VENDOR_SPECIFIC_MAX_LEN 1016
194
195/*
196 * struct smp_req - This structure simply unionizes the existing request
197 * structures into a common request type.
198 *
199 * XXX: This data structure may need to go to scsi/sas.h
200 */
201struct smp_req {
202 u8 type; /* byte 0 */
203 u8 func; /* byte 1 */
204 u8 alloc_resp_len; /* byte 2 */
205 u8 req_len; /* byte 3 */
206
207 union { /* bytes 4-N */
208 u32 smp_req_gen;
209 struct smp_req_phy_id phy_id;
210 struct smp_req_phycntl phy_cntl;
211 struct smp_req_conf_rtinfo conf_rt_info;
212 u8 vendor[SMP_REQ_VENDOR_SPECIFIC_MAX_LEN];
213 };
214} __packed;
215
109#endif 216#endif