ctl_tpc.c (275878) | ctl_tpc.c (275881) |
---|---|
1/*- 2 * Copyright (c) 2014 Alexander Motin <mav@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2014 Alexander Motin <mav@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: stable/10/sys/cam/ctl/ctl_tpc.c 275878 2014-12-18 08:22:16Z mav $"); | 28__FBSDID("$FreeBSD: stable/10/sys/cam/ctl/ctl_tpc.c 275881 2014-12-18 08:25:00Z mav $"); |
29 30#include <sys/param.h> 31#include <sys/systm.h> 32#include <sys/kernel.h> 33#include <sys/types.h> 34#include <sys/lock.h> 35#include <sys/module.h> 36#include <sys/mutex.h> --- 383 unchanged lines hidden (view full) --- 420 scsi_ulto2b(SVPD_TPC_GCO, gco_ptr->desc_type); 421 scsi_ulto2b(sizeof(*gco_ptr) - 4, gco_ptr->desc_length); 422 scsi_ulto4b(TPC_MAX_LISTS, gco_ptr->total_concurrent_copies); 423 scsi_ulto4b(TPC_MAX_LISTS, gco_ptr->maximum_identified_concurrent_copies); 424 scsi_ulto4b(TPC_MAX_SEG, gco_ptr->maximum_segment_length); 425 gco_ptr->data_segment_granularity = 0; 426 gco_ptr->inline_data_granularity = 0; 427 | 29 30#include <sys/param.h> 31#include <sys/systm.h> 32#include <sys/kernel.h> 33#include <sys/types.h> 34#include <sys/lock.h> 35#include <sys/module.h> 36#include <sys/mutex.h> --- 383 unchanged lines hidden (view full) --- 420 scsi_ulto2b(SVPD_TPC_GCO, gco_ptr->desc_type); 421 scsi_ulto2b(sizeof(*gco_ptr) - 4, gco_ptr->desc_length); 422 scsi_ulto4b(TPC_MAX_LISTS, gco_ptr->total_concurrent_copies); 423 scsi_ulto4b(TPC_MAX_LISTS, gco_ptr->maximum_identified_concurrent_copies); 424 scsi_ulto4b(TPC_MAX_SEG, gco_ptr->maximum_segment_length); 425 gco_ptr->data_segment_granularity = 0; 426 gco_ptr->inline_data_granularity = 0; 427 |
428 ctsio->scsi_status = SCSI_STATUS_OK; | 428 ctl_set_success(ctsio); |
429 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 430 ctsio->be_move_done = ctl_config_move_done; 431 ctl_datamove((union ctl_io *)ctsio); 432 433 return (CTL_RETVAL_COMPLETE); 434} 435 436int --- 45 unchanged lines hidden (view full) --- 482 data->inline_data_granularity = 0; 483 data->held_data_granularity = 0; 484 data->implemented_descriptor_list_length = 4; 485 data->list_of_implemented_descriptor_type_codes[0] = EC_SEG_B2B; 486 data->list_of_implemented_descriptor_type_codes[1] = EC_SEG_VERIFY; 487 data->list_of_implemented_descriptor_type_codes[2] = EC_SEG_REGISTER_KEY; 488 data->list_of_implemented_descriptor_type_codes[3] = EC_CSCD_ID; 489 | 429 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 430 ctsio->be_move_done = ctl_config_move_done; 431 ctl_datamove((union ctl_io *)ctsio); 432 433 return (CTL_RETVAL_COMPLETE); 434} 435 436int --- 45 unchanged lines hidden (view full) --- 482 data->inline_data_granularity = 0; 483 data->held_data_granularity = 0; 484 data->implemented_descriptor_list_length = 4; 485 data->list_of_implemented_descriptor_type_codes[0] = EC_SEG_B2B; 486 data->list_of_implemented_descriptor_type_codes[1] = EC_SEG_VERIFY; 487 data->list_of_implemented_descriptor_type_codes[2] = EC_SEG_REGISTER_KEY; 488 data->list_of_implemented_descriptor_type_codes[3] = EC_CSCD_ID; 489 |
490 ctl_set_success(ctsio); |
|
490 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 491 ctsio->be_move_done = ctl_config_move_done; | 491 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 492 ctsio->be_move_done = ctl_config_move_done; |
492 | |
493 ctl_datamove((union ctl_io *)ctsio); 494 return (retval); 495} 496 497static struct tpc_list * 498tpc_find_list(struct ctl_lun *lun, uint32_t list_id, uint32_t init_idx) 499{ 500 struct tpc_list *list; --- 78 unchanged lines hidden (view full) --- 579 if (list_copy.curbytes <= UINT32_MAX) { 580 data->transfer_count_units = RCS_TC_BYTES; 581 scsi_ulto4b(list_copy.curbytes, data->transfer_count); 582 } else { 583 data->transfer_count_units = RCS_TC_MBYTES; 584 scsi_ulto4b(list_copy.curbytes >> 20, data->transfer_count); 585 } 586 | 493 ctl_datamove((union ctl_io *)ctsio); 494 return (retval); 495} 496 497static struct tpc_list * 498tpc_find_list(struct ctl_lun *lun, uint32_t list_id, uint32_t init_idx) 499{ 500 struct tpc_list *list; --- 78 unchanged lines hidden (view full) --- 579 if (list_copy.curbytes <= UINT32_MAX) { 580 data->transfer_count_units = RCS_TC_BYTES; 581 scsi_ulto4b(list_copy.curbytes, data->transfer_count); 582 } else { 583 data->transfer_count_units = RCS_TC_MBYTES; 584 scsi_ulto4b(list_copy.curbytes >> 20, data->transfer_count); 585 } 586 |
587 ctl_set_success(ctsio); |
|
587 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 588 ctsio->be_move_done = ctl_config_move_done; | 588 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 589 ctsio->be_move_done = ctl_config_move_done; |
589 | |
590 ctl_datamove((union ctl_io *)ctsio); 591 return (retval); 592} 593 594int 595ctl_receive_copy_failure_details(struct ctl_scsiio *ctsio) 596{ 597 struct ctl_lun *lun; --- 53 unchanged lines hidden (view full) --- 651 scsi_ulto4b(sizeof(*data) - 4 + list_copy.sense_len, 652 data->available_data); 653 data->copy_command_status = RCS_CCS_ERROR; 654 } else 655 scsi_ulto4b(0, data->available_data); 656 scsi_ulto2b(list_copy.sense_len, data->sense_data_length); 657 memcpy(data->sense_data, &list_copy.sense_data, list_copy.sense_len); 658 | 590 ctl_datamove((union ctl_io *)ctsio); 591 return (retval); 592} 593 594int 595ctl_receive_copy_failure_details(struct ctl_scsiio *ctsio) 596{ 597 struct ctl_lun *lun; --- 53 unchanged lines hidden (view full) --- 651 scsi_ulto4b(sizeof(*data) - 4 + list_copy.sense_len, 652 data->available_data); 653 data->copy_command_status = RCS_CCS_ERROR; 654 } else 655 scsi_ulto4b(0, data->available_data); 656 scsi_ulto2b(list_copy.sense_len, data->sense_data_length); 657 memcpy(data->sense_data, &list_copy.sense_data, list_copy.sense_len); 658 |
659 ctl_set_success(ctsio); |
|
659 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 660 ctsio->be_move_done = ctl_config_move_done; | 660 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 661 ctsio->be_move_done = ctl_config_move_done; |
661 | |
662 ctl_datamove((union ctl_io *)ctsio); 663 return (retval); 664} 665 666int 667ctl_receive_copy_status_lid4(struct ctl_scsiio *ctsio) 668{ 669 struct ctl_lun *lun; --- 67 unchanged lines hidden (view full) --- 737 scsi_ulto4b(UINT32_MAX, data->estimated_status_update_delay); 738 data->transfer_count_units = RCS_TC_BYTES; 739 scsi_u64to8b(list_copy.curbytes, data->transfer_count); 740 scsi_ulto2b(list_copy.curseg, data->segments_processed); 741 data->length_of_the_sense_data_field = list_copy.sense_len; 742 data->sense_data_length = list_copy.sense_len; 743 memcpy(data->sense_data, &list_copy.sense_data, list_copy.sense_len); 744 | 662 ctl_datamove((union ctl_io *)ctsio); 663 return (retval); 664} 665 666int 667ctl_receive_copy_status_lid4(struct ctl_scsiio *ctsio) 668{ 669 struct ctl_lun *lun; --- 67 unchanged lines hidden (view full) --- 737 scsi_ulto4b(UINT32_MAX, data->estimated_status_update_delay); 738 data->transfer_count_units = RCS_TC_BYTES; 739 scsi_u64to8b(list_copy.curbytes, data->transfer_count); 740 scsi_ulto2b(list_copy.curseg, data->segments_processed); 741 data->length_of_the_sense_data_field = list_copy.sense_len; 742 data->sense_data_length = list_copy.sense_len; 743 memcpy(data->sense_data, &list_copy.sense_data, list_copy.sense_len); 744 |
745 ctl_set_success(ctsio); |
|
745 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 746 ctsio->be_move_done = ctl_config_move_done; | 746 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 747 ctsio->be_move_done = ctl_config_move_done; |
747 | |
748 ctl_datamove((union ctl_io *)ctsio); 749 return (retval); 750} 751 752int 753ctl_copy_operation_abort(struct ctl_scsiio *ctsio) 754{ 755 struct ctl_lun *lun; --- 721 unchanged lines hidden (view full) --- 1477 struct tpc_io *tio, *tior; 1478 1479 /* 1480 * Very minimal retry logic. We basically retry if we got an error 1481 * back, and the retry count is greater than 0. If we ever want 1482 * more sophisticated initiator type behavior, the CAM error 1483 * recovery code in ../common might be helpful. 1484 */ | 748 ctl_datamove((union ctl_io *)ctsio); 749 return (retval); 750} 751 752int 753ctl_copy_operation_abort(struct ctl_scsiio *ctsio) 754{ 755 struct ctl_lun *lun; --- 721 unchanged lines hidden (view full) --- 1477 struct tpc_io *tio, *tior; 1478 1479 /* 1480 * Very minimal retry logic. We basically retry if we got an error 1481 * back, and the retry count is greater than 0. If we ever want 1482 * more sophisticated initiator type behavior, the CAM error 1483 * recovery code in ../common might be helpful. 1484 */ |
1485// if ((io->io_hdr.status & CTL_STATUS_MASK) != CTL_SUCCESS) 1486// ctl_io_error_print(io, NULL); | |
1487 tio = io->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptr; 1488 if (((io->io_hdr.status & CTL_STATUS_MASK) != CTL_SUCCESS) 1489 && (io->io_hdr.retries > 0)) { 1490 ctl_io_status old_status; 1491 tpc_error_action error_action; 1492 1493 error_action = tpc_error_parse(io); 1494 switch (error_action & TPC_ERR_MASK) { --- 680 unchanged lines hidden (view full) --- 2175 if (list_copy.res_token_valid) { 2176 scsi_ulto2b(0, &ptr[4]); 2177 memcpy(&ptr[6], list_copy.res_token, sizeof(list_copy.res_token)); 2178 } 2179/* 2180 printf("RRTI(list=%u) valid=%d\n", 2181 scsi_4btoul(cdb->list_identifier), list_copy.res_token_valid); 2182*/ | 1485 tio = io->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptr; 1486 if (((io->io_hdr.status & CTL_STATUS_MASK) != CTL_SUCCESS) 1487 && (io->io_hdr.retries > 0)) { 1488 ctl_io_status old_status; 1489 tpc_error_action error_action; 1490 1491 error_action = tpc_error_parse(io); 1492 switch (error_action & TPC_ERR_MASK) { --- 680 unchanged lines hidden (view full) --- 2173 if (list_copy.res_token_valid) { 2174 scsi_ulto2b(0, &ptr[4]); 2175 memcpy(&ptr[6], list_copy.res_token, sizeof(list_copy.res_token)); 2176 } 2177/* 2178 printf("RRTI(list=%u) valid=%d\n", 2179 scsi_4btoul(cdb->list_identifier), list_copy.res_token_valid); 2180*/ |
2181 ctl_set_success(ctsio); |
|
2183 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 2184 ctsio->be_move_done = ctl_config_move_done; | 2182 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 2183 ctsio->be_move_done = ctl_config_move_done; |
2185 | |
2186 ctl_datamove((union ctl_io *)ctsio); 2187 return (retval); 2188} 2189 2190int 2191ctl_report_all_rod_tokens(struct ctl_scsiio *ctsio) 2192{ 2193 struct ctl_lun *lun; --- 47 unchanged lines hidden (view full) --- 2241 token->token, 96); 2242 i++; 2243 } 2244 mtx_unlock(&control_softc->ctl_lock); 2245 scsi_ulto4b(sizeof(*data) - 4 + i * 96, data->available_data); 2246/* 2247 printf("RART tokens=%d\n", i); 2248*/ | 2184 ctl_datamove((union ctl_io *)ctsio); 2185 return (retval); 2186} 2187 2188int 2189ctl_report_all_rod_tokens(struct ctl_scsiio *ctsio) 2190{ 2191 struct ctl_lun *lun; --- 47 unchanged lines hidden (view full) --- 2239 token->token, 96); 2240 i++; 2241 } 2242 mtx_unlock(&control_softc->ctl_lock); 2243 scsi_ulto4b(sizeof(*data) - 4 + i * 96, data->available_data); 2244/* 2245 printf("RART tokens=%d\n", i); 2246*/ |
2247 ctl_set_success(ctsio); |
|
2249 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 2250 ctsio->be_move_done = ctl_config_move_done; | 2248 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 2249 ctsio->be_move_done = ctl_config_move_done; |
2251 | |
2252 ctl_datamove((union ctl_io *)ctsio); 2253 return (retval); 2254} 2255 | 2250 ctl_datamove((union ctl_io *)ctsio); 2251 return (retval); 2252} 2253 |