diff options
author | Dan Williams <dan.j.williams@intel.com> | 2011-06-27 14:56:41 -0400 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2011-07-03 07:04:51 -0400 |
commit | ba7cb22342a66505a831bb7e4541fef90e0193c9 (patch) | |
tree | 759acb8d84333dd0e61ac5c157ef3c4661bfe74c /drivers/scsi/isci/request.c | |
parent | db0562509800a2d4cb5cb14a66413c30484f165c (diff) |
isci: rename / clean up scic_sds_stp_request
* Rename scic_sds_stp_request to isci_stp_request
* Remove the unused fields and union indirection
Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/scsi/isci/request.c')
-rw-r--r-- | drivers/scsi/isci/request.c | 147 |
1 files changed, 68 insertions, 79 deletions
diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c index 3c7ed4e61b4a..8520626b02fa 100644 --- a/drivers/scsi/isci/request.c +++ b/drivers/scsi/isci/request.c | |||
@@ -433,24 +433,20 @@ static enum sci_status | |||
433 | scic_sds_stp_pio_request_construct(struct scic_sds_request *sci_req, | 433 | scic_sds_stp_pio_request_construct(struct scic_sds_request *sci_req, |
434 | bool copy_rx_frame) | 434 | bool copy_rx_frame) |
435 | { | 435 | { |
436 | struct scic_sds_stp_request *stp_req = &sci_req->stp.req; | 436 | struct isci_stp_request *stp_req = &sci_req->stp.req; |
437 | struct scic_sds_stp_pio_request *pio = &stp_req->type.pio; | ||
438 | 437 | ||
439 | scu_stp_raw_request_construct_task_context(sci_req); | 438 | scu_stp_raw_request_construct_task_context(sci_req); |
440 | 439 | ||
441 | pio->current_transfer_bytes = 0; | 440 | stp_req->status = 0; |
442 | pio->ending_error = 0; | 441 | stp_req->sgl.offset = 0; |
443 | pio->ending_status = 0; | 442 | stp_req->sgl.set = SCU_SGL_ELEMENT_PAIR_A; |
444 | |||
445 | pio->request_current.sgl_offset = 0; | ||
446 | pio->request_current.sgl_set = SCU_SGL_ELEMENT_PAIR_A; | ||
447 | 443 | ||
448 | if (copy_rx_frame) { | 444 | if (copy_rx_frame) { |
449 | scic_sds_request_build_sgl(sci_req); | 445 | scic_sds_request_build_sgl(sci_req); |
450 | pio->request_current.sgl_index = 0; | 446 | stp_req->sgl.index = 0; |
451 | } else { | 447 | } else { |
452 | /* The user does not want the data copied to the SGL buffer location */ | 448 | /* The user does not want the data copied to the SGL buffer location */ |
453 | pio->request_current.sgl_index = -1; | 449 | stp_req->sgl.index = -1; |
454 | } | 450 | } |
455 | 451 | ||
456 | return SCI_SUCCESS; | 452 | return SCI_SUCCESS; |
@@ -1151,22 +1147,22 @@ void scic_stp_io_request_set_ncq_tag(struct scic_sds_request *req, | |||
1151 | req->tc->type.stp.ncq_tag = ncq_tag; | 1147 | req->tc->type.stp.ncq_tag = ncq_tag; |
1152 | } | 1148 | } |
1153 | 1149 | ||
1154 | static struct scu_sgl_element *pio_sgl_next(struct scic_sds_stp_request *stp_req) | 1150 | static struct scu_sgl_element *pio_sgl_next(struct isci_stp_request *stp_req) |
1155 | { | 1151 | { |
1156 | struct scu_sgl_element *sgl; | 1152 | struct scu_sgl_element *sgl; |
1157 | struct scu_sgl_element_pair *sgl_pair; | 1153 | struct scu_sgl_element_pair *sgl_pair; |
1158 | struct scic_sds_request *sci_req = to_sci_req(stp_req); | 1154 | struct scic_sds_request *sci_req = to_sci_req(stp_req); |
1159 | struct scic_sds_request_pio_sgl *pio_sgl = &stp_req->type.pio.request_current; | 1155 | struct isci_stp_pio_sgl *pio_sgl = &stp_req->sgl; |
1160 | 1156 | ||
1161 | sgl_pair = to_sgl_element_pair(sci_req, pio_sgl->sgl_index); | 1157 | sgl_pair = to_sgl_element_pair(sci_req, pio_sgl->index); |
1162 | if (!sgl_pair) | 1158 | if (!sgl_pair) |
1163 | sgl = NULL; | 1159 | sgl = NULL; |
1164 | else if (pio_sgl->sgl_set == SCU_SGL_ELEMENT_PAIR_A) { | 1160 | else if (pio_sgl->set == SCU_SGL_ELEMENT_PAIR_A) { |
1165 | if (sgl_pair->B.address_lower == 0 && | 1161 | if (sgl_pair->B.address_lower == 0 && |
1166 | sgl_pair->B.address_upper == 0) { | 1162 | sgl_pair->B.address_upper == 0) { |
1167 | sgl = NULL; | 1163 | sgl = NULL; |
1168 | } else { | 1164 | } else { |
1169 | pio_sgl->sgl_set = SCU_SGL_ELEMENT_PAIR_B; | 1165 | pio_sgl->set = SCU_SGL_ELEMENT_PAIR_B; |
1170 | sgl = &sgl_pair->B; | 1166 | sgl = &sgl_pair->B; |
1171 | } | 1167 | } |
1172 | } else { | 1168 | } else { |
@@ -1174,9 +1170,9 @@ static struct scu_sgl_element *pio_sgl_next(struct scic_sds_stp_request *stp_req | |||
1174 | sgl_pair->next_pair_upper == 0) { | 1170 | sgl_pair->next_pair_upper == 0) { |
1175 | sgl = NULL; | 1171 | sgl = NULL; |
1176 | } else { | 1172 | } else { |
1177 | pio_sgl->sgl_index++; | 1173 | pio_sgl->index++; |
1178 | pio_sgl->sgl_set = SCU_SGL_ELEMENT_PAIR_A; | 1174 | pio_sgl->set = SCU_SGL_ELEMENT_PAIR_A; |
1179 | sgl_pair = to_sgl_element_pair(sci_req, pio_sgl->sgl_index); | 1175 | sgl_pair = to_sgl_element_pair(sci_req, pio_sgl->index); |
1180 | sgl = &sgl_pair->A; | 1176 | sgl = &sgl_pair->A; |
1181 | } | 1177 | } |
1182 | } | 1178 | } |
@@ -1221,7 +1217,7 @@ static enum sci_status scic_sds_stp_request_pio_data_out_trasmit_data_frame( | |||
1221 | struct scic_sds_request *sci_req, | 1217 | struct scic_sds_request *sci_req, |
1222 | u32 length) | 1218 | u32 length) |
1223 | { | 1219 | { |
1224 | struct scic_sds_stp_request *stp_req = &sci_req->stp.req; | 1220 | struct isci_stp_request *stp_req = &sci_req->stp.req; |
1225 | struct scu_task_context *task_context = sci_req->tc; | 1221 | struct scu_task_context *task_context = sci_req->tc; |
1226 | struct scu_sgl_element_pair *sgl_pair; | 1222 | struct scu_sgl_element_pair *sgl_pair; |
1227 | struct scu_sgl_element *current_sgl; | 1223 | struct scu_sgl_element *current_sgl; |
@@ -1229,8 +1225,8 @@ static enum sci_status scic_sds_stp_request_pio_data_out_trasmit_data_frame( | |||
1229 | /* Recycle the TC and reconstruct it for sending out DATA FIS containing | 1225 | /* Recycle the TC and reconstruct it for sending out DATA FIS containing |
1230 | * for the data from current_sgl+offset for the input length | 1226 | * for the data from current_sgl+offset for the input length |
1231 | */ | 1227 | */ |
1232 | sgl_pair = to_sgl_element_pair(sci_req, stp_req->type.pio.request_current.sgl_index); | 1228 | sgl_pair = to_sgl_element_pair(sci_req, stp_req->sgl.index); |
1233 | if (stp_req->type.pio.request_current.sgl_set == SCU_SGL_ELEMENT_PAIR_A) | 1229 | if (stp_req->sgl.set == SCU_SGL_ELEMENT_PAIR_A) |
1234 | current_sgl = &sgl_pair->A; | 1230 | current_sgl = &sgl_pair->A; |
1235 | else | 1231 | else |
1236 | current_sgl = &sgl_pair->B; | 1232 | current_sgl = &sgl_pair->B; |
@@ -1247,54 +1243,48 @@ static enum sci_status scic_sds_stp_request_pio_data_out_trasmit_data_frame( | |||
1247 | 1243 | ||
1248 | static enum sci_status scic_sds_stp_request_pio_data_out_transmit_data(struct scic_sds_request *sci_req) | 1244 | static enum sci_status scic_sds_stp_request_pio_data_out_transmit_data(struct scic_sds_request *sci_req) |
1249 | { | 1245 | { |
1250 | 1246 | struct isci_stp_request *stp_req = &sci_req->stp.req; | |
1251 | struct scu_sgl_element *current_sgl; | ||
1252 | u32 sgl_offset; | ||
1253 | u32 remaining_bytes_in_current_sgl = 0; | ||
1254 | enum sci_status status = SCI_SUCCESS; | ||
1255 | struct scic_sds_stp_request *stp_req = &sci_req->stp.req; | ||
1256 | struct scu_sgl_element_pair *sgl_pair; | 1247 | struct scu_sgl_element_pair *sgl_pair; |
1248 | struct scu_sgl_element *sgl; | ||
1249 | enum sci_status status; | ||
1250 | u32 offset; | ||
1251 | u32 len = 0; | ||
1257 | 1252 | ||
1258 | sgl_offset = stp_req->type.pio.request_current.sgl_offset; | 1253 | offset = stp_req->sgl.offset; |
1259 | sgl_pair = to_sgl_element_pair(sci_req, stp_req->type.pio.request_current.sgl_index); | 1254 | sgl_pair = to_sgl_element_pair(sci_req, stp_req->sgl.index); |
1260 | if (WARN_ONCE(!sgl_pair, "%s: null sgl element", __func__)) | 1255 | if (WARN_ONCE(!sgl_pair, "%s: null sgl element", __func__)) |
1261 | return SCI_FAILURE; | 1256 | return SCI_FAILURE; |
1262 | 1257 | ||
1263 | if (stp_req->type.pio.request_current.sgl_set == SCU_SGL_ELEMENT_PAIR_A) { | 1258 | if (stp_req->sgl.set == SCU_SGL_ELEMENT_PAIR_A) { |
1264 | current_sgl = &sgl_pair->A; | 1259 | sgl = &sgl_pair->A; |
1265 | remaining_bytes_in_current_sgl = sgl_pair->A.length - sgl_offset; | 1260 | len = sgl_pair->A.length - offset; |
1266 | } else { | 1261 | } else { |
1267 | current_sgl = &sgl_pair->B; | 1262 | sgl = &sgl_pair->B; |
1268 | remaining_bytes_in_current_sgl = sgl_pair->B.length - sgl_offset; | 1263 | len = sgl_pair->B.length - offset; |
1269 | } | 1264 | } |
1270 | 1265 | ||
1271 | if (stp_req->type.pio.pio_transfer_bytes > 0) { | 1266 | if (stp_req->pio_len == 0) |
1272 | if (stp_req->type.pio.pio_transfer_bytes >= remaining_bytes_in_current_sgl) { | 1267 | return SCI_SUCCESS; |
1273 | /* recycle the TC and send the H2D Data FIS from (current sgl + sgl_offset) and length = remaining_bytes_in_current_sgl */ | ||
1274 | status = scic_sds_stp_request_pio_data_out_trasmit_data_frame(sci_req, remaining_bytes_in_current_sgl); | ||
1275 | if (status == SCI_SUCCESS) { | ||
1276 | stp_req->type.pio.pio_transfer_bytes -= remaining_bytes_in_current_sgl; | ||
1277 | |||
1278 | /* update the current sgl, sgl_offset and save for future */ | ||
1279 | current_sgl = pio_sgl_next(stp_req); | ||
1280 | sgl_offset = 0; | ||
1281 | } | ||
1282 | } else if (stp_req->type.pio.pio_transfer_bytes < remaining_bytes_in_current_sgl) { | ||
1283 | /* recycle the TC and send the H2D Data FIS from (current sgl + sgl_offset) and length = type.pio.pio_transfer_bytes */ | ||
1284 | scic_sds_stp_request_pio_data_out_trasmit_data_frame(sci_req, stp_req->type.pio.pio_transfer_bytes); | ||
1285 | 1268 | ||
1286 | if (status == SCI_SUCCESS) { | 1269 | if (stp_req->pio_len >= len) { |
1287 | /* Sgl offset will be adjusted and saved for future */ | 1270 | status = scic_sds_stp_request_pio_data_out_trasmit_data_frame(sci_req, len); |
1288 | sgl_offset += stp_req->type.pio.pio_transfer_bytes; | 1271 | if (status != SCI_SUCCESS) |
1289 | current_sgl->address_lower += stp_req->type.pio.pio_transfer_bytes; | 1272 | return status; |
1290 | stp_req->type.pio.pio_transfer_bytes = 0; | 1273 | stp_req->pio_len -= len; |
1291 | } | 1274 | |
1292 | } | 1275 | /* update the current sgl, offset and save for future */ |
1276 | sgl = pio_sgl_next(stp_req); | ||
1277 | offset = 0; | ||
1278 | } else if (stp_req->pio_len < len) { | ||
1279 | scic_sds_stp_request_pio_data_out_trasmit_data_frame(sci_req, stp_req->pio_len); | ||
1280 | |||
1281 | /* Sgl offset will be adjusted and saved for future */ | ||
1282 | offset += stp_req->pio_len; | ||
1283 | sgl->address_lower += stp_req->pio_len; | ||
1284 | stp_req->pio_len = 0; | ||
1293 | } | 1285 | } |
1294 | 1286 | ||
1295 | if (status == SCI_SUCCESS) { | 1287 | stp_req->sgl.offset = offset; |
1296 | stp_req->type.pio.request_current.sgl_offset = sgl_offset; | ||
1297 | } | ||
1298 | 1288 | ||
1299 | return status; | 1289 | return status; |
1300 | } | 1290 | } |
@@ -1309,7 +1299,7 @@ static enum sci_status scic_sds_stp_request_pio_data_out_transmit_data(struct sc | |||
1309 | * specified data region. enum sci_status | 1299 | * specified data region. enum sci_status |
1310 | */ | 1300 | */ |
1311 | static enum sci_status | 1301 | static enum sci_status |
1312 | scic_sds_stp_request_pio_data_in_copy_data_buffer(struct scic_sds_stp_request *stp_req, | 1302 | scic_sds_stp_request_pio_data_in_copy_data_buffer(struct isci_stp_request *stp_req, |
1313 | u8 *data_buf, u32 len) | 1303 | u8 *data_buf, u32 len) |
1314 | { | 1304 | { |
1315 | struct scic_sds_request *sci_req; | 1305 | struct scic_sds_request *sci_req; |
@@ -1356,7 +1346,7 @@ scic_sds_stp_request_pio_data_in_copy_data_buffer(struct scic_sds_stp_request *s | |||
1356 | * Copy the data buffer to the io request data region. enum sci_status | 1346 | * Copy the data buffer to the io request data region. enum sci_status |
1357 | */ | 1347 | */ |
1358 | static enum sci_status scic_sds_stp_request_pio_data_in_copy_data( | 1348 | static enum sci_status scic_sds_stp_request_pio_data_in_copy_data( |
1359 | struct scic_sds_stp_request *sci_req, | 1349 | struct isci_stp_request *stp_req, |
1360 | u8 *data_buffer) | 1350 | u8 *data_buffer) |
1361 | { | 1351 | { |
1362 | enum sci_status status; | 1352 | enum sci_status status; |
@@ -1364,19 +1354,19 @@ static enum sci_status scic_sds_stp_request_pio_data_in_copy_data( | |||
1364 | /* | 1354 | /* |
1365 | * If there is less than 1K remaining in the transfer request | 1355 | * If there is less than 1K remaining in the transfer request |
1366 | * copy just the data for the transfer */ | 1356 | * copy just the data for the transfer */ |
1367 | if (sci_req->type.pio.pio_transfer_bytes < SCU_MAX_FRAME_BUFFER_SIZE) { | 1357 | if (stp_req->pio_len < SCU_MAX_FRAME_BUFFER_SIZE) { |
1368 | status = scic_sds_stp_request_pio_data_in_copy_data_buffer( | 1358 | status = scic_sds_stp_request_pio_data_in_copy_data_buffer( |
1369 | sci_req, data_buffer, sci_req->type.pio.pio_transfer_bytes); | 1359 | stp_req, data_buffer, stp_req->pio_len); |
1370 | 1360 | ||
1371 | if (status == SCI_SUCCESS) | 1361 | if (status == SCI_SUCCESS) |
1372 | sci_req->type.pio.pio_transfer_bytes = 0; | 1362 | stp_req->pio_len = 0; |
1373 | } else { | 1363 | } else { |
1374 | /* We are transfering the whole frame so copy */ | 1364 | /* We are transfering the whole frame so copy */ |
1375 | status = scic_sds_stp_request_pio_data_in_copy_data_buffer( | 1365 | status = scic_sds_stp_request_pio_data_in_copy_data_buffer( |
1376 | sci_req, data_buffer, SCU_MAX_FRAME_BUFFER_SIZE); | 1366 | stp_req, data_buffer, SCU_MAX_FRAME_BUFFER_SIZE); |
1377 | 1367 | ||
1378 | if (status == SCI_SUCCESS) | 1368 | if (status == SCI_SUCCESS) |
1379 | sci_req->type.pio.pio_transfer_bytes -= SCU_MAX_FRAME_BUFFER_SIZE; | 1369 | stp_req->pio_len -= SCU_MAX_FRAME_BUFFER_SIZE; |
1380 | } | 1370 | } |
1381 | 1371 | ||
1382 | return status; | 1372 | return status; |
@@ -1419,18 +1409,18 @@ pio_data_out_tx_done_tc_event(struct scic_sds_request *sci_req, | |||
1419 | { | 1409 | { |
1420 | enum sci_status status = SCI_SUCCESS; | 1410 | enum sci_status status = SCI_SUCCESS; |
1421 | bool all_frames_transferred = false; | 1411 | bool all_frames_transferred = false; |
1422 | struct scic_sds_stp_request *stp_req = &sci_req->stp.req; | 1412 | struct isci_stp_request *stp_req = &sci_req->stp.req; |
1423 | 1413 | ||
1424 | switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) { | 1414 | switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) { |
1425 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD): | 1415 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD): |
1426 | /* Transmit data */ | 1416 | /* Transmit data */ |
1427 | if (stp_req->type.pio.pio_transfer_bytes != 0) { | 1417 | if (stp_req->pio_len != 0) { |
1428 | status = scic_sds_stp_request_pio_data_out_transmit_data(sci_req); | 1418 | status = scic_sds_stp_request_pio_data_out_transmit_data(sci_req); |
1429 | if (status == SCI_SUCCESS) { | 1419 | if (status == SCI_SUCCESS) { |
1430 | if (stp_req->type.pio.pio_transfer_bytes == 0) | 1420 | if (stp_req->pio_len == 0) |
1431 | all_frames_transferred = true; | 1421 | all_frames_transferred = true; |
1432 | } | 1422 | } |
1433 | } else if (stp_req->type.pio.pio_transfer_bytes == 0) { | 1423 | } else if (stp_req->pio_len == 0) { |
1434 | /* | 1424 | /* |
1435 | * this will happen if the all data is written at the | 1425 | * this will happen if the all data is written at the |
1436 | * first time after the pio setup fis is received | 1426 | * first time after the pio setup fis is received |
@@ -1507,7 +1497,7 @@ scic_sds_io_request_frame_handler(struct scic_sds_request *sci_req, | |||
1507 | u32 frame_index) | 1497 | u32 frame_index) |
1508 | { | 1498 | { |
1509 | struct scic_sds_controller *scic = sci_req->owning_controller; | 1499 | struct scic_sds_controller *scic = sci_req->owning_controller; |
1510 | struct scic_sds_stp_request *stp_req = &sci_req->stp.req; | 1500 | struct isci_stp_request *stp_req = &sci_req->stp.req; |
1511 | enum sci_base_request_states state; | 1501 | enum sci_base_request_states state; |
1512 | enum sci_status status; | 1502 | enum sci_status status; |
1513 | ssize_t word_cnt; | 1503 | ssize_t word_cnt; |
@@ -1727,16 +1717,16 @@ scic_sds_io_request_frame_handler(struct scic_sds_request *sci_req, | |||
1727 | */ | 1717 | */ |
1728 | 1718 | ||
1729 | /* transfer_count: first 16bits in the 4th dword */ | 1719 | /* transfer_count: first 16bits in the 4th dword */ |
1730 | stp_req->type.pio.pio_transfer_bytes = frame_buffer[3] & 0xffff; | 1720 | stp_req->pio_len = frame_buffer[3] & 0xffff; |
1731 | 1721 | ||
1732 | /* ending_status: 4th byte in the 3rd dword */ | 1722 | /* status: 4th byte in the 3rd dword */ |
1733 | stp_req->type.pio.ending_status = (frame_buffer[2] >> 24) & 0xff; | 1723 | stp_req->status = (frame_buffer[2] >> 24) & 0xff; |
1734 | 1724 | ||
1735 | scic_sds_controller_copy_sata_response(&sci_req->stp.rsp, | 1725 | scic_sds_controller_copy_sata_response(&sci_req->stp.rsp, |
1736 | frame_header, | 1726 | frame_header, |
1737 | frame_buffer); | 1727 | frame_buffer); |
1738 | 1728 | ||
1739 | sci_req->stp.rsp.status = stp_req->type.pio.ending_status; | 1729 | sci_req->stp.rsp.status = stp_req->status; |
1740 | 1730 | ||
1741 | /* The next state is dependent on whether the | 1731 | /* The next state is dependent on whether the |
1742 | * request was PIO Data-in or Data out | 1732 | * request was PIO Data-in or Data out |
@@ -1839,9 +1829,9 @@ scic_sds_io_request_frame_handler(struct scic_sds_request *sci_req, | |||
1839 | return status; | 1829 | return status; |
1840 | } | 1830 | } |
1841 | 1831 | ||
1842 | if (stp_req->type.pio.request_current.sgl_index < 0) { | 1832 | if (stp_req->sgl.index < 0) { |
1843 | sci_req->saved_rx_frame_index = frame_index; | 1833 | sci_req->saved_rx_frame_index = frame_index; |
1844 | stp_req->type.pio.pio_transfer_bytes = 0; | 1834 | stp_req->pio_len = 0; |
1845 | } else { | 1835 | } else { |
1846 | scic_sds_unsolicited_frame_control_get_buffer(&scic->uf_control, | 1836 | scic_sds_unsolicited_frame_control_get_buffer(&scic->uf_control, |
1847 | frame_index, | 1837 | frame_index, |
@@ -1857,11 +1847,10 @@ scic_sds_io_request_frame_handler(struct scic_sds_request *sci_req, | |||
1857 | /* Check for the end of the transfer, are there more | 1847 | /* Check for the end of the transfer, are there more |
1858 | * bytes remaining for this data transfer | 1848 | * bytes remaining for this data transfer |
1859 | */ | 1849 | */ |
1860 | if (status != SCI_SUCCESS || | 1850 | if (status != SCI_SUCCESS || stp_req->pio_len != 0) |
1861 | stp_req->type.pio.pio_transfer_bytes != 0) | ||
1862 | return status; | 1851 | return status; |
1863 | 1852 | ||
1864 | if ((stp_req->type.pio.ending_status & ATA_BUSY) == 0) { | 1853 | if ((stp_req->status & ATA_BUSY) == 0) { |
1865 | scic_sds_request_set_status(sci_req, | 1854 | scic_sds_request_set_status(sci_req, |
1866 | SCU_TASK_DONE_CHECK_RESPONSE, | 1855 | SCU_TASK_DONE_CHECK_RESPONSE, |
1867 | SCI_FAILURE_IO_RESPONSE_VALID); | 1856 | SCI_FAILURE_IO_RESPONSE_VALID); |