ctl_tpc.c (312570) | ctl_tpc.c (312834) |
---|---|
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/11/sys/cam/ctl/ctl_tpc.c 312570 2017-01-21 08:29:40Z mav $"); | 28__FBSDID("$FreeBSD: stable/11/sys/cam/ctl/ctl_tpc.c 312834 2017-01-26 20:49:19Z 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> --- 209 unchanged lines hidden (view full) --- 246 free(token, M_CTL); 247 } 248 mtx_unlock(&softc->tpc_lock); 249} 250 251int 252ctl_inquiry_evpd_tpc(struct ctl_scsiio *ctsio, int alloc_len) 253{ | 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> --- 209 unchanged lines hidden (view full) --- 246 free(token, M_CTL); 247 } 248 mtx_unlock(&softc->tpc_lock); 249} 250 251int 252ctl_inquiry_evpd_tpc(struct ctl_scsiio *ctsio, int alloc_len) 253{ |
254 struct ctl_lun *lun = CTL_LUN(ctsio); |
|
254 struct scsi_vpd_tpc *tpc_ptr; 255 struct scsi_vpd_tpc_descriptor *d_ptr; 256 struct scsi_vpd_tpc_descriptor_bdrl *bdrl_ptr; 257 struct scsi_vpd_tpc_descriptor_sc *sc_ptr; 258 struct scsi_vpd_tpc_descriptor_sc_descr *scd_ptr; 259 struct scsi_vpd_tpc_descriptor_pd *pd_ptr; 260 struct scsi_vpd_tpc_descriptor_sd *sd_ptr; 261 struct scsi_vpd_tpc_descriptor_sdid *sdid_ptr; 262 struct scsi_vpd_tpc_descriptor_rtf *rtf_ptr; 263 struct scsi_vpd_tpc_descriptor_rtf_block *rtfb_ptr; 264 struct scsi_vpd_tpc_descriptor_srt *srt_ptr; 265 struct scsi_vpd_tpc_descriptor_srtd *srtd_ptr; 266 struct scsi_vpd_tpc_descriptor_gco *gco_ptr; | 255 struct scsi_vpd_tpc *tpc_ptr; 256 struct scsi_vpd_tpc_descriptor *d_ptr; 257 struct scsi_vpd_tpc_descriptor_bdrl *bdrl_ptr; 258 struct scsi_vpd_tpc_descriptor_sc *sc_ptr; 259 struct scsi_vpd_tpc_descriptor_sc_descr *scd_ptr; 260 struct scsi_vpd_tpc_descriptor_pd *pd_ptr; 261 struct scsi_vpd_tpc_descriptor_sd *sd_ptr; 262 struct scsi_vpd_tpc_descriptor_sdid *sdid_ptr; 263 struct scsi_vpd_tpc_descriptor_rtf *rtf_ptr; 264 struct scsi_vpd_tpc_descriptor_rtf_block *rtfb_ptr; 265 struct scsi_vpd_tpc_descriptor_srt *srt_ptr; 266 struct scsi_vpd_tpc_descriptor_srtd *srtd_ptr; 267 struct scsi_vpd_tpc_descriptor_gco *gco_ptr; |
267 struct ctl_lun *lun; | |
268 int data_len; 269 | 268 int data_len; 269 |
270 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; 271 | |
272 data_len = sizeof(struct scsi_vpd_tpc) + 273 sizeof(struct scsi_vpd_tpc_descriptor_bdrl) + 274 roundup2(sizeof(struct scsi_vpd_tpc_descriptor_sc) + 275 2 * sizeof(struct scsi_vpd_tpc_descriptor_sc_descr) + 11, 4) + 276 sizeof(struct scsi_vpd_tpc_descriptor_pd) + 277 roundup2(sizeof(struct scsi_vpd_tpc_descriptor_sd) + 4, 4) + 278 roundup2(sizeof(struct scsi_vpd_tpc_descriptor_sdid) + 2, 4) + 279 sizeof(struct scsi_vpd_tpc_descriptor_rtf) + --- 236 unchanged lines hidden (view full) --- 516 break; 517 } 518 return (list); 519} 520 521int 522ctl_receive_copy_status_lid1(struct ctl_scsiio *ctsio) 523{ | 270 data_len = sizeof(struct scsi_vpd_tpc) + 271 sizeof(struct scsi_vpd_tpc_descriptor_bdrl) + 272 roundup2(sizeof(struct scsi_vpd_tpc_descriptor_sc) + 273 2 * sizeof(struct scsi_vpd_tpc_descriptor_sc_descr) + 11, 4) + 274 sizeof(struct scsi_vpd_tpc_descriptor_pd) + 275 roundup2(sizeof(struct scsi_vpd_tpc_descriptor_sd) + 4, 4) + 276 roundup2(sizeof(struct scsi_vpd_tpc_descriptor_sdid) + 2, 4) + 277 sizeof(struct scsi_vpd_tpc_descriptor_rtf) + --- 236 unchanged lines hidden (view full) --- 514 break; 515 } 516 return (list); 517} 518 519int 520ctl_receive_copy_status_lid1(struct ctl_scsiio *ctsio) 521{ |
524 struct ctl_lun *lun; | 522 struct ctl_lun *lun = CTL_LUN(ctsio); |
525 struct scsi_receive_copy_status_lid1 *cdb; 526 struct scsi_receive_copy_status_lid1_data *data; 527 struct tpc_list *list; 528 struct tpc_list list_copy; 529 int retval; 530 int alloc_len, total_len; 531 uint32_t list_id; 532 533 CTL_DEBUG_PRINT(("ctl_receive_copy_status_lid1\n")); 534 535 cdb = (struct scsi_receive_copy_status_lid1 *)ctsio->cdb; | 523 struct scsi_receive_copy_status_lid1 *cdb; 524 struct scsi_receive_copy_status_lid1_data *data; 525 struct tpc_list *list; 526 struct tpc_list list_copy; 527 int retval; 528 int alloc_len, total_len; 529 uint32_t list_id; 530 531 CTL_DEBUG_PRINT(("ctl_receive_copy_status_lid1\n")); 532 533 cdb = (struct scsi_receive_copy_status_lid1 *)ctsio->cdb; |
536 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; 537 | |
538 retval = CTL_RETVAL_COMPLETE; 539 540 list_id = cdb->list_identifier; 541 mtx_lock(&lun->lun_lock); 542 list = tpc_find_list(lun, list_id, 543 ctl_get_initindex(&ctsio->io_hdr.nexus)); 544 if (list == NULL) { 545 mtx_unlock(&lun->lun_lock); --- 52 unchanged lines hidden (view full) --- 598 ctsio->be_move_done = ctl_config_move_done; 599 ctl_datamove((union ctl_io *)ctsio); 600 return (retval); 601} 602 603int 604ctl_receive_copy_failure_details(struct ctl_scsiio *ctsio) 605{ | 534 retval = CTL_RETVAL_COMPLETE; 535 536 list_id = cdb->list_identifier; 537 mtx_lock(&lun->lun_lock); 538 list = tpc_find_list(lun, list_id, 539 ctl_get_initindex(&ctsio->io_hdr.nexus)); 540 if (list == NULL) { 541 mtx_unlock(&lun->lun_lock); --- 52 unchanged lines hidden (view full) --- 594 ctsio->be_move_done = ctl_config_move_done; 595 ctl_datamove((union ctl_io *)ctsio); 596 return (retval); 597} 598 599int 600ctl_receive_copy_failure_details(struct ctl_scsiio *ctsio) 601{ |
606 struct ctl_lun *lun; | 602 struct ctl_lun *lun = CTL_LUN(ctsio); |
607 struct scsi_receive_copy_failure_details *cdb; 608 struct scsi_receive_copy_failure_details_data *data; 609 struct tpc_list *list; 610 struct tpc_list list_copy; 611 int retval; 612 int alloc_len, total_len; 613 uint32_t list_id; 614 615 CTL_DEBUG_PRINT(("ctl_receive_copy_failure_details\n")); 616 617 cdb = (struct scsi_receive_copy_failure_details *)ctsio->cdb; | 603 struct scsi_receive_copy_failure_details *cdb; 604 struct scsi_receive_copy_failure_details_data *data; 605 struct tpc_list *list; 606 struct tpc_list list_copy; 607 int retval; 608 int alloc_len, total_len; 609 uint32_t list_id; 610 611 CTL_DEBUG_PRINT(("ctl_receive_copy_failure_details\n")); 612 613 cdb = (struct scsi_receive_copy_failure_details *)ctsio->cdb; |
618 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; 619 | |
620 retval = CTL_RETVAL_COMPLETE; 621 622 list_id = cdb->list_identifier; 623 mtx_lock(&lun->lun_lock); 624 list = tpc_find_list(lun, list_id, 625 ctl_get_initindex(&ctsio->io_hdr.nexus)); 626 if (list == NULL || !list->completed) { 627 mtx_unlock(&lun->lun_lock); --- 42 unchanged lines hidden (view full) --- 670 ctsio->be_move_done = ctl_config_move_done; 671 ctl_datamove((union ctl_io *)ctsio); 672 return (retval); 673} 674 675int 676ctl_receive_copy_status_lid4(struct ctl_scsiio *ctsio) 677{ | 614 retval = CTL_RETVAL_COMPLETE; 615 616 list_id = cdb->list_identifier; 617 mtx_lock(&lun->lun_lock); 618 list = tpc_find_list(lun, list_id, 619 ctl_get_initindex(&ctsio->io_hdr.nexus)); 620 if (list == NULL || !list->completed) { 621 mtx_unlock(&lun->lun_lock); --- 42 unchanged lines hidden (view full) --- 664 ctsio->be_move_done = ctl_config_move_done; 665 ctl_datamove((union ctl_io *)ctsio); 666 return (retval); 667} 668 669int 670ctl_receive_copy_status_lid4(struct ctl_scsiio *ctsio) 671{ |
678 struct ctl_lun *lun; | 672 struct ctl_lun *lun = CTL_LUN(ctsio); |
679 struct scsi_receive_copy_status_lid4 *cdb; 680 struct scsi_receive_copy_status_lid4_data *data; 681 struct tpc_list *list; 682 struct tpc_list list_copy; 683 int retval; 684 int alloc_len, total_len; 685 uint32_t list_id; 686 687 CTL_DEBUG_PRINT(("ctl_receive_copy_status_lid4\n")); 688 689 cdb = (struct scsi_receive_copy_status_lid4 *)ctsio->cdb; | 673 struct scsi_receive_copy_status_lid4 *cdb; 674 struct scsi_receive_copy_status_lid4_data *data; 675 struct tpc_list *list; 676 struct tpc_list list_copy; 677 int retval; 678 int alloc_len, total_len; 679 uint32_t list_id; 680 681 CTL_DEBUG_PRINT(("ctl_receive_copy_status_lid4\n")); 682 683 cdb = (struct scsi_receive_copy_status_lid4 *)ctsio->cdb; |
690 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; 691 | |
692 retval = CTL_RETVAL_COMPLETE; 693 694 list_id = scsi_4btoul(cdb->list_identifier); 695 mtx_lock(&lun->lun_lock); 696 list = tpc_find_list(lun, list_id, 697 ctl_get_initindex(&ctsio->io_hdr.nexus)); 698 if (list == NULL) { 699 mtx_unlock(&lun->lun_lock); --- 56 unchanged lines hidden (view full) --- 756 ctsio->be_move_done = ctl_config_move_done; 757 ctl_datamove((union ctl_io *)ctsio); 758 return (retval); 759} 760 761int 762ctl_copy_operation_abort(struct ctl_scsiio *ctsio) 763{ | 684 retval = CTL_RETVAL_COMPLETE; 685 686 list_id = scsi_4btoul(cdb->list_identifier); 687 mtx_lock(&lun->lun_lock); 688 list = tpc_find_list(lun, list_id, 689 ctl_get_initindex(&ctsio->io_hdr.nexus)); 690 if (list == NULL) { 691 mtx_unlock(&lun->lun_lock); --- 56 unchanged lines hidden (view full) --- 748 ctsio->be_move_done = ctl_config_move_done; 749 ctl_datamove((union ctl_io *)ctsio); 750 return (retval); 751} 752 753int 754ctl_copy_operation_abort(struct ctl_scsiio *ctsio) 755{ |
764 struct ctl_lun *lun; | 756 struct ctl_lun *lun = CTL_LUN(ctsio); |
765 struct scsi_copy_operation_abort *cdb; 766 struct tpc_list *list; 767 int retval; 768 uint32_t list_id; 769 770 CTL_DEBUG_PRINT(("ctl_copy_operation_abort\n")); 771 772 cdb = (struct scsi_copy_operation_abort *)ctsio->cdb; | 757 struct scsi_copy_operation_abort *cdb; 758 struct tpc_list *list; 759 int retval; 760 uint32_t list_id; 761 762 CTL_DEBUG_PRINT(("ctl_copy_operation_abort\n")); 763 764 cdb = (struct scsi_copy_operation_abort *)ctsio->cdb; |
773 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; 774 | |
775 retval = CTL_RETVAL_COMPLETE; 776 777 list_id = scsi_4btoul(cdb->list_identifier); 778 mtx_lock(&lun->lun_lock); 779 list = tpc_find_list(lun, list_id, 780 ctl_get_initindex(&ctsio->io_hdr.nexus)); 781 if (list == NULL) { 782 mtx_unlock(&lun->lun_lock); --- 917 unchanged lines hidden (view full) --- 1700 } 1701 if (atomic_fetchadd_int(&tio->list->tbdio, -1) == 1) 1702 tpc_process(tio->list); 1703} 1704 1705int 1706ctl_extended_copy_lid1(struct ctl_scsiio *ctsio) 1707{ | 765 retval = CTL_RETVAL_COMPLETE; 766 767 list_id = scsi_4btoul(cdb->list_identifier); 768 mtx_lock(&lun->lun_lock); 769 list = tpc_find_list(lun, list_id, 770 ctl_get_initindex(&ctsio->io_hdr.nexus)); 771 if (list == NULL) { 772 mtx_unlock(&lun->lun_lock); --- 917 unchanged lines hidden (view full) --- 1690 } 1691 if (atomic_fetchadd_int(&tio->list->tbdio, -1) == 1) 1692 tpc_process(tio->list); 1693} 1694 1695int 1696ctl_extended_copy_lid1(struct ctl_scsiio *ctsio) 1697{ |
1698 struct ctl_lun *lun = CTL_LUN(ctsio); |
|
1708 struct scsi_extended_copy *cdb; 1709 struct scsi_extended_copy_lid1_data *data; 1710 struct scsi_ec_cscd *cscd; 1711 struct scsi_ec_segment *seg; | 1699 struct scsi_extended_copy *cdb; 1700 struct scsi_extended_copy_lid1_data *data; 1701 struct scsi_ec_cscd *cscd; 1702 struct scsi_ec_segment *seg; |
1712 struct ctl_lun *lun; | |
1713 struct tpc_list *list, *tlist; 1714 uint8_t *ptr; 1715 char *value; 1716 int len, off, lencscd, lenseg, leninl, nseg; 1717 1718 CTL_DEBUG_PRINT(("ctl_extended_copy_lid1\n")); 1719 | 1703 struct tpc_list *list, *tlist; 1704 uint8_t *ptr; 1705 char *value; 1706 int len, off, lencscd, lenseg, leninl, nseg; 1707 1708 CTL_DEBUG_PRINT(("ctl_extended_copy_lid1\n")); 1709 |
1720 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; | |
1721 cdb = (struct scsi_extended_copy *)ctsio->cdb; 1722 len = scsi_4btoul(cdb->length); 1723 1724 if (len == 0) { 1725 ctl_set_success(ctsio); 1726 goto done; 1727 } 1728 if (len < sizeof(struct scsi_extended_copy_lid1_data) || --- 127 unchanged lines hidden (view full) --- 1856 } 1857 ctl_done((union ctl_io *)ctsio); 1858 return (CTL_RETVAL_COMPLETE); 1859} 1860 1861int 1862ctl_extended_copy_lid4(struct ctl_scsiio *ctsio) 1863{ | 1710 cdb = (struct scsi_extended_copy *)ctsio->cdb; 1711 len = scsi_4btoul(cdb->length); 1712 1713 if (len == 0) { 1714 ctl_set_success(ctsio); 1715 goto done; 1716 } 1717 if (len < sizeof(struct scsi_extended_copy_lid1_data) || --- 127 unchanged lines hidden (view full) --- 1845 } 1846 ctl_done((union ctl_io *)ctsio); 1847 return (CTL_RETVAL_COMPLETE); 1848} 1849 1850int 1851ctl_extended_copy_lid4(struct ctl_scsiio *ctsio) 1852{ |
1853 struct ctl_lun *lun = CTL_LUN(ctsio); |
|
1864 struct scsi_extended_copy *cdb; 1865 struct scsi_extended_copy_lid4_data *data; 1866 struct scsi_ec_cscd *cscd; 1867 struct scsi_ec_segment *seg; | 1854 struct scsi_extended_copy *cdb; 1855 struct scsi_extended_copy_lid4_data *data; 1856 struct scsi_ec_cscd *cscd; 1857 struct scsi_ec_segment *seg; |
1868 struct ctl_lun *lun; | |
1869 struct tpc_list *list, *tlist; 1870 uint8_t *ptr; 1871 char *value; 1872 int len, off, lencscd, lenseg, leninl, nseg; 1873 1874 CTL_DEBUG_PRINT(("ctl_extended_copy_lid4\n")); 1875 | 1858 struct tpc_list *list, *tlist; 1859 uint8_t *ptr; 1860 char *value; 1861 int len, off, lencscd, lenseg, leninl, nseg; 1862 1863 CTL_DEBUG_PRINT(("ctl_extended_copy_lid4\n")); 1864 |
1876 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; | |
1877 cdb = (struct scsi_extended_copy *)ctsio->cdb; 1878 len = scsi_4btoul(cdb->length); 1879 1880 if (len == 0) { 1881 ctl_set_success(ctsio); 1882 goto done; 1883 } 1884 if (len < sizeof(struct scsi_extended_copy_lid4_data) || --- 174 unchanged lines hidden (view full) --- 2059 } else 2060 targid_len = 32; 2061 arc4rand(&token->body[120 + targid_len], 384 - targid_len, 0); 2062}; 2063 2064int 2065ctl_populate_token(struct ctl_scsiio *ctsio) 2066{ | 1865 cdb = (struct scsi_extended_copy *)ctsio->cdb; 1866 len = scsi_4btoul(cdb->length); 1867 1868 if (len == 0) { 1869 ctl_set_success(ctsio); 1870 goto done; 1871 } 1872 if (len < sizeof(struct scsi_extended_copy_lid4_data) || --- 174 unchanged lines hidden (view full) --- 2047 } else 2048 targid_len = 32; 2049 arc4rand(&token->body[120 + targid_len], 384 - targid_len, 0); 2050}; 2051 2052int 2053ctl_populate_token(struct ctl_scsiio *ctsio) 2054{ |
2055 struct ctl_softc *softc = CTL_SOFTC(ctsio); 2056 struct ctl_port *port = CTL_PORT(ctsio); 2057 struct ctl_lun *lun = CTL_LUN(ctsio); |
|
2067 struct scsi_populate_token *cdb; 2068 struct scsi_populate_token_data *data; | 2058 struct scsi_populate_token *cdb; 2059 struct scsi_populate_token_data *data; |
2069 struct ctl_softc *softc; 2070 struct ctl_lun *lun; 2071 struct ctl_port *port; | |
2072 struct tpc_list *list, *tlist; 2073 struct tpc_token *token; 2074 uint64_t lba; 2075 int len, lendata, lendesc; 2076 2077 CTL_DEBUG_PRINT(("ctl_populate_token\n")); 2078 | 2060 struct tpc_list *list, *tlist; 2061 struct tpc_token *token; 2062 uint64_t lba; 2063 int len, lendata, lendesc; 2064 2065 CTL_DEBUG_PRINT(("ctl_populate_token\n")); 2066 |
2079 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; 2080 softc = lun->ctl_softc; 2081 port = softc->ctl_ports[ctsio->io_hdr.nexus.targ_port]; | |
2082 cdb = (struct scsi_populate_token *)ctsio->cdb; 2083 len = scsi_4btoul(cdb->length); 2084 2085 if (len < sizeof(struct scsi_populate_token_data) || 2086 len > sizeof(struct scsi_populate_token_data) + 2087 TPC_MAX_SEGS * sizeof(struct scsi_range_desc)) { 2088 ctl_set_invalid_field(ctsio, /*sks_valid*/ 1, /*command*/ 1, 2089 /*field*/ 9, /*bit_valid*/ 0, /*bit*/ 0); --- 137 unchanged lines hidden (view full) --- 2227 } 2228 ctl_done((union ctl_io *)ctsio); 2229 return (CTL_RETVAL_COMPLETE); 2230} 2231 2232int 2233ctl_write_using_token(struct ctl_scsiio *ctsio) 2234{ | 2067 cdb = (struct scsi_populate_token *)ctsio->cdb; 2068 len = scsi_4btoul(cdb->length); 2069 2070 if (len < sizeof(struct scsi_populate_token_data) || 2071 len > sizeof(struct scsi_populate_token_data) + 2072 TPC_MAX_SEGS * sizeof(struct scsi_range_desc)) { 2073 ctl_set_invalid_field(ctsio, /*sks_valid*/ 1, /*command*/ 1, 2074 /*field*/ 9, /*bit_valid*/ 0, /*bit*/ 0); --- 137 unchanged lines hidden (view full) --- 2212 } 2213 ctl_done((union ctl_io *)ctsio); 2214 return (CTL_RETVAL_COMPLETE); 2215} 2216 2217int 2218ctl_write_using_token(struct ctl_scsiio *ctsio) 2219{ |
2220 struct ctl_softc *softc = CTL_SOFTC(ctsio); 2221 struct ctl_lun *lun = CTL_LUN(ctsio); |
|
2235 struct scsi_write_using_token *cdb; 2236 struct scsi_write_using_token_data *data; | 2222 struct scsi_write_using_token *cdb; 2223 struct scsi_write_using_token_data *data; |
2237 struct ctl_softc *softc; 2238 struct ctl_lun *lun; | |
2239 struct tpc_list *list, *tlist; 2240 struct tpc_token *token; 2241 uint64_t lba; 2242 int len, lendata, lendesc; 2243 2244 CTL_DEBUG_PRINT(("ctl_write_using_token\n")); 2245 | 2224 struct tpc_list *list, *tlist; 2225 struct tpc_token *token; 2226 uint64_t lba; 2227 int len, lendata, lendesc; 2228 2229 CTL_DEBUG_PRINT(("ctl_write_using_token\n")); 2230 |
2246 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; 2247 softc = lun->ctl_softc; | |
2248 cdb = (struct scsi_write_using_token *)ctsio->cdb; 2249 len = scsi_4btoul(cdb->length); 2250 2251 if (len < sizeof(struct scsi_write_using_token_data) || 2252 len > sizeof(struct scsi_write_using_token_data) + 2253 TPC_MAX_SEGS * sizeof(struct scsi_range_desc)) { 2254 ctl_set_invalid_field(ctsio, /*sks_valid*/ 1, /*command*/ 1, 2255 /*field*/ 9, /*bit_valid*/ 0, /*bit*/ 0); --- 128 unchanged lines hidden (view full) --- 2384 } 2385 ctl_done((union ctl_io *)ctsio); 2386 return (CTL_RETVAL_COMPLETE); 2387} 2388 2389int 2390ctl_receive_rod_token_information(struct ctl_scsiio *ctsio) 2391{ | 2231 cdb = (struct scsi_write_using_token *)ctsio->cdb; 2232 len = scsi_4btoul(cdb->length); 2233 2234 if (len < sizeof(struct scsi_write_using_token_data) || 2235 len > sizeof(struct scsi_write_using_token_data) + 2236 TPC_MAX_SEGS * sizeof(struct scsi_range_desc)) { 2237 ctl_set_invalid_field(ctsio, /*sks_valid*/ 1, /*command*/ 1, 2238 /*field*/ 9, /*bit_valid*/ 0, /*bit*/ 0); --- 128 unchanged lines hidden (view full) --- 2367 } 2368 ctl_done((union ctl_io *)ctsio); 2369 return (CTL_RETVAL_COMPLETE); 2370} 2371 2372int 2373ctl_receive_rod_token_information(struct ctl_scsiio *ctsio) 2374{ |
2392 struct ctl_lun *lun; | 2375 struct ctl_lun *lun = CTL_LUN(ctsio); |
2393 struct scsi_receive_rod_token_information *cdb; 2394 struct scsi_receive_copy_status_lid4_data *data; 2395 struct tpc_list *list; 2396 struct tpc_list list_copy; 2397 uint8_t *ptr; 2398 int retval; 2399 int alloc_len, total_len, token_len; 2400 uint32_t list_id; 2401 2402 CTL_DEBUG_PRINT(("ctl_receive_rod_token_information\n")); 2403 2404 cdb = (struct scsi_receive_rod_token_information *)ctsio->cdb; | 2376 struct scsi_receive_rod_token_information *cdb; 2377 struct scsi_receive_copy_status_lid4_data *data; 2378 struct tpc_list *list; 2379 struct tpc_list list_copy; 2380 uint8_t *ptr; 2381 int retval; 2382 int alloc_len, total_len, token_len; 2383 uint32_t list_id; 2384 2385 CTL_DEBUG_PRINT(("ctl_receive_rod_token_information\n")); 2386 2387 cdb = (struct scsi_receive_rod_token_information *)ctsio->cdb; |
2405 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; 2406 | |
2407 retval = CTL_RETVAL_COMPLETE; 2408 2409 list_id = scsi_4btoul(cdb->list_identifier); 2410 mtx_lock(&lun->lun_lock); 2411 list = tpc_find_list(lun, list_id, 2412 ctl_get_initindex(&ctsio->io_hdr.nexus)); 2413 if (list == NULL) { 2414 mtx_unlock(&lun->lun_lock); --- 67 unchanged lines hidden (view full) --- 2482 ctsio->be_move_done = ctl_config_move_done; 2483 ctl_datamove((union ctl_io *)ctsio); 2484 return (retval); 2485} 2486 2487int 2488ctl_report_all_rod_tokens(struct ctl_scsiio *ctsio) 2489{ | 2388 retval = CTL_RETVAL_COMPLETE; 2389 2390 list_id = scsi_4btoul(cdb->list_identifier); 2391 mtx_lock(&lun->lun_lock); 2392 list = tpc_find_list(lun, list_id, 2393 ctl_get_initindex(&ctsio->io_hdr.nexus)); 2394 if (list == NULL) { 2395 mtx_unlock(&lun->lun_lock); --- 67 unchanged lines hidden (view full) --- 2463 ctsio->be_move_done = ctl_config_move_done; 2464 ctl_datamove((union ctl_io *)ctsio); 2465 return (retval); 2466} 2467 2468int 2469ctl_report_all_rod_tokens(struct ctl_scsiio *ctsio) 2470{ |
2490 struct ctl_softc *softc; 2491 struct ctl_lun *lun; | 2471 struct ctl_softc *softc = CTL_SOFTC(ctsio); |
2492 struct scsi_report_all_rod_tokens *cdb; 2493 struct scsi_report_all_rod_tokens_data *data; 2494 struct tpc_token *token; 2495 int retval; 2496 int alloc_len, total_len, tokens, i; 2497 2498 CTL_DEBUG_PRINT(("ctl_receive_rod_token_information\n")); 2499 2500 cdb = (struct scsi_report_all_rod_tokens *)ctsio->cdb; | 2472 struct scsi_report_all_rod_tokens *cdb; 2473 struct scsi_report_all_rod_tokens_data *data; 2474 struct tpc_token *token; 2475 int retval; 2476 int alloc_len, total_len, tokens, i; 2477 2478 CTL_DEBUG_PRINT(("ctl_receive_rod_token_information\n")); 2479 2480 cdb = (struct scsi_report_all_rod_tokens *)ctsio->cdb; |
2501 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; 2502 softc = lun->ctl_softc; 2503 | |
2504 retval = CTL_RETVAL_COMPLETE; 2505 2506 tokens = 0; 2507 mtx_lock(&softc->tpc_lock); 2508 TAILQ_FOREACH(token, &softc->tpc_tokens, links) 2509 tokens++; 2510 mtx_unlock(&softc->tpc_lock); 2511 if (tokens > 512) --- 43 unchanged lines hidden --- | 2481 retval = CTL_RETVAL_COMPLETE; 2482 2483 tokens = 0; 2484 mtx_lock(&softc->tpc_lock); 2485 TAILQ_FOREACH(token, &softc->tpc_tokens, links) 2486 tokens++; 2487 mtx_unlock(&softc->tpc_lock); 2488 if (tokens > 512) --- 43 unchanged lines hidden --- |