ctl.c (275009) | ctl.c (275058) |
---|---|
1/*- 2 * Copyright (c) 2003-2009 Silicon Graphics International Corp. 3 * Copyright (c) 2012 The FreeBSD Foundation 4 * All rights reserved. 5 * 6 * Portions of this software were developed by Edward Tomasz Napierala 7 * under sponsorship from the FreeBSD Foundation. 8 * --- 28 unchanged lines hidden (view full) --- 37 * CAM Target Layer, a SCSI device emulation subsystem. 38 * 39 * Author: Ken Merry <ken@FreeBSD.org> 40 */ 41 42#define _CTL_C 43 44#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2003-2009 Silicon Graphics International Corp. 3 * Copyright (c) 2012 The FreeBSD Foundation 4 * All rights reserved. 5 * 6 * Portions of this software were developed by Edward Tomasz Napierala 7 * under sponsorship from the FreeBSD Foundation. 8 * --- 28 unchanged lines hidden (view full) --- 37 * CAM Target Layer, a SCSI device emulation subsystem. 38 * 39 * Author: Ken Merry <ken@FreeBSD.org> 40 */ 41 42#define _CTL_C 43 44#include <sys/cdefs.h> |
45__FBSDID("$FreeBSD: head/sys/cam/ctl/ctl.c 275009 2014-11-25 06:11:05Z mav $"); | 45__FBSDID("$FreeBSD: head/sys/cam/ctl/ctl.c 275058 2014-11-25 17:53:35Z mav $"); |
46 47#include <sys/param.h> 48#include <sys/systm.h> 49#include <sys/ctype.h> 50#include <sys/kernel.h> 51#include <sys/types.h> 52#include <sys/kthread.h> 53#include <sys/bio.h> --- 4937 unchanged lines hidden (view full) --- 4991 * Backend "memory move is complete" callback for requests that never 4992 * make it down to say RAIDCore's configuration code. 4993 */ 4994int 4995ctl_config_move_done(union ctl_io *io) 4996{ 4997 int retval; 4998 | 46 47#include <sys/param.h> 48#include <sys/systm.h> 49#include <sys/ctype.h> 50#include <sys/kernel.h> 51#include <sys/types.h> 52#include <sys/kthread.h> 53#include <sys/bio.h> --- 4937 unchanged lines hidden (view full) --- 4991 * Backend "memory move is complete" callback for requests that never 4992 * make it down to say RAIDCore's configuration code. 4993 */ 4994int 4995ctl_config_move_done(union ctl_io *io) 4996{ 4997 int retval; 4998 |
4999 retval = CTL_RETVAL_COMPLETE; 5000 5001 | |
5002 CTL_DEBUG_PRINT(("ctl_config_move_done\n")); | 4999 CTL_DEBUG_PRINT(("ctl_config_move_done\n")); |
5003 /* 5004 * XXX KDM this shouldn't happen, but what if it does? 5005 */ 5006 if (io->io_hdr.io_type != CTL_IO_SCSI) 5007 panic("I/O type isn't CTL_IO_SCSI!"); | 5000 KASSERT(io->io_hdr.io_type == CTL_IO_SCSI, 5001 ("Config I/O type isn't CTL_IO_SCSI (%d)!", io->io_hdr.io_type)); |
5008 | 5002 |
5009 if ((io->io_hdr.port_status == 0) 5010 && ((io->io_hdr.flags & CTL_FLAG_ABORT) == 0) 5011 && ((io->io_hdr.status & CTL_STATUS_MASK) == CTL_STATUS_NONE)) 5012 io->io_hdr.status = CTL_SUCCESS; 5013 else if ((io->io_hdr.port_status != 0) 5014 && ((io->io_hdr.flags & CTL_FLAG_ABORT) == 0) 5015 && ((io->io_hdr.status & CTL_STATUS_MASK) == CTL_STATUS_NONE)){ | 5003 if ((io->io_hdr.port_status != 0) && 5004 ((io->io_hdr.status & CTL_STATUS_MASK) == CTL_STATUS_NONE || 5005 (io->io_hdr.status & CTL_STATUS_MASK) == CTL_SUCCESS)) { |
5016 /* 5017 * For hardware error sense keys, the sense key 5018 * specific value is defined to be a retry count, 5019 * but we use it to pass back an internal FETD 5020 * error code. XXX KDM Hopefully the FETD is only 5021 * using 16 bits for an error code, since that's 5022 * all the space we have in the sks field. 5023 */ 5024 ctl_set_internal_failure(&io->scsiio, 5025 /*sks_valid*/ 1, 5026 /*retry_count*/ 5027 io->io_hdr.port_status); | 5006 /* 5007 * For hardware error sense keys, the sense key 5008 * specific value is defined to be a retry count, 5009 * but we use it to pass back an internal FETD 5010 * error code. XXX KDM Hopefully the FETD is only 5011 * using 16 bits for an error code, since that's 5012 * all the space we have in the sks field. 5013 */ 5014 ctl_set_internal_failure(&io->scsiio, 5015 /*sks_valid*/ 1, 5016 /*retry_count*/ 5017 io->io_hdr.port_status); |
5028 if (io->io_hdr.flags & CTL_FLAG_ALLOCATED) 5029 free(io->scsiio.kern_data_ptr, M_CTL); 5030 ctl_done(io); 5031 goto bailout; | |
5032 } 5033 | 5018 } 5019 |
5034 if (((io->io_hdr.flags & CTL_FLAG_DATA_MASK) == CTL_FLAG_DATA_IN) 5035 || ((io->io_hdr.status & CTL_STATUS_MASK) != CTL_SUCCESS) 5036 || ((io->io_hdr.flags & CTL_FLAG_ABORT) != 0)) { | 5020 if (((io->io_hdr.flags & CTL_FLAG_DATA_MASK) == CTL_FLAG_DATA_IN) || 5021 ((io->io_hdr.status & CTL_STATUS_MASK) != CTL_STATUS_NONE && 5022 (io->io_hdr.status & CTL_STATUS_MASK) != CTL_SUCCESS) || 5023 ((io->io_hdr.flags & CTL_FLAG_ABORT) != 0)) { |
5037 /* 5038 * XXX KDM just assuming a single pointer here, and not a 5039 * S/G list. If we start using S/G lists for config data, 5040 * we'll need to know how to clean them up here as well. 5041 */ 5042 if (io->io_hdr.flags & CTL_FLAG_ALLOCATED) 5043 free(io->scsiio.kern_data_ptr, M_CTL); | 5024 /* 5025 * XXX KDM just assuming a single pointer here, and not a 5026 * S/G list. If we start using S/G lists for config data, 5027 * we'll need to know how to clean them up here as well. 5028 */ 5029 if (io->io_hdr.flags & CTL_FLAG_ALLOCATED) 5030 free(io->scsiio.kern_data_ptr, M_CTL); |
5044 /* Hopefully the user has already set the status... */ | |
5045 ctl_done(io); | 5031 ctl_done(io); |
5032 retval = CTL_RETVAL_COMPLETE; |
|
5046 } else { 5047 /* 5048 * XXX KDM now we need to continue data movement. Some 5049 * options: 5050 * - call ctl_scsiio() again? We don't do this for data 5051 * writes, because for those at least we know ahead of 5052 * time where the write will go and how long it is. For 5053 * config writes, though, that information is largely --- 6 unchanged lines hidden (view full) --- 5060 ctl_data_print(io); 5061 5062 /* 5063 * XXX KDM call ctl_scsiio() again for now, and check flag 5064 * bits to see whether we're allocated or not. 5065 */ 5066 retval = ctl_scsiio(&io->scsiio); 5067 } | 5033 } else { 5034 /* 5035 * XXX KDM now we need to continue data movement. Some 5036 * options: 5037 * - call ctl_scsiio() again? We don't do this for data 5038 * writes, because for those at least we know ahead of 5039 * time where the write will go and how long it is. For 5040 * config writes, though, that information is largely --- 6 unchanged lines hidden (view full) --- 5047 ctl_data_print(io); 5048 5049 /* 5050 * XXX KDM call ctl_scsiio() again for now, and check flag 5051 * bits to see whether we're allocated or not. 5052 */ 5053 retval = ctl_scsiio(&io->scsiio); 5054 } |
5068bailout: | |
5069 return (retval); 5070} 5071 5072/* 5073 * This gets called by a backend driver when it is done with a 5074 * data_submit method. 5075 */ 5076void --- 129 unchanged lines hidden (view full) --- 5206 * released, though, by the initiator who made it or by one of 5207 * several reset type events. 5208 */ 5209 if ((lun->flags & CTL_LUN_RESERVED) && (lun->res_idx == residx)) 5210 lun->flags &= ~CTL_LUN_RESERVED; 5211 5212 mtx_unlock(&lun->lun_lock); 5213 | 5055 return (retval); 5056} 5057 5058/* 5059 * This gets called by a backend driver when it is done with a 5060 * data_submit method. 5061 */ 5062void --- 129 unchanged lines hidden (view full) --- 5192 * released, though, by the initiator who made it or by one of 5193 * several reset type events. 5194 */ 5195 if ((lun->flags & CTL_LUN_RESERVED) && (lun->res_idx == residx)) 5196 lun->flags &= ~CTL_LUN_RESERVED; 5197 5198 mtx_unlock(&lun->lun_lock); 5199 |
5214 ctl_set_success(ctsio); 5215 | |
5216 if (ctsio->io_hdr.flags & CTL_FLAG_ALLOCATED) { 5217 free(ctsio->kern_data_ptr, M_CTL); 5218 ctsio->io_hdr.flags &= ~CTL_FLAG_ALLOCATED; 5219 } 5220 | 5200 if (ctsio->io_hdr.flags & CTL_FLAG_ALLOCATED) { 5201 free(ctsio->kern_data_ptr, M_CTL); 5202 ctsio->io_hdr.flags &= ~CTL_FLAG_ALLOCATED; 5203 } 5204 |
5205 ctl_set_success(ctsio); |
|
5221 ctl_done((union ctl_io *)ctsio); 5222 return (CTL_RETVAL_COMPLETE); 5223} 5224 5225int 5226ctl_scsi_reserve(struct ctl_scsiio *ctsio) 5227{ 5228 int extent, thirdparty, longid; --- 447 unchanged lines hidden (view full) --- 5676 } 5677 ctsio->kern_data_ptr = lun->write_buffer + buffer_offset; 5678 } 5679 ctsio->kern_data_len = len; 5680 ctsio->kern_total_len = len; 5681 ctsio->kern_data_resid = 0; 5682 ctsio->kern_rel_offset = 0; 5683 ctsio->kern_sg_entries = 0; | 5206 ctl_done((union ctl_io *)ctsio); 5207 return (CTL_RETVAL_COMPLETE); 5208} 5209 5210int 5211ctl_scsi_reserve(struct ctl_scsiio *ctsio) 5212{ 5213 int extent, thirdparty, longid; --- 447 unchanged lines hidden (view full) --- 5661 } 5662 ctsio->kern_data_ptr = lun->write_buffer + buffer_offset; 5663 } 5664 ctsio->kern_data_len = len; 5665 ctsio->kern_total_len = len; 5666 ctsio->kern_data_resid = 0; 5667 ctsio->kern_rel_offset = 0; 5668 ctsio->kern_sg_entries = 0; |
5669 ctl_set_success(ctsio); |
|
5684 ctsio->be_move_done = ctl_config_move_done; 5685 ctl_datamove((union ctl_io *)ctsio); | 5670 ctsio->be_move_done = ctl_config_move_done; 5671 ctl_datamove((union ctl_io *)ctsio); |
5686 | |
5687 return (CTL_RETVAL_COMPLETE); 5688} 5689 5690int 5691ctl_write_buffer(struct ctl_scsiio *ctsio) 5692{ 5693 struct scsi_write_buffer *cdb; 5694 struct ctl_lun *lun; --- 46 unchanged lines hidden (view full) --- 5741 ctsio->kern_sg_entries = 0; 5742 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 5743 ctsio->be_move_done = ctl_config_move_done; 5744 ctl_datamove((union ctl_io *)ctsio); 5745 5746 return (CTL_RETVAL_COMPLETE); 5747 } 5748 | 5672 return (CTL_RETVAL_COMPLETE); 5673} 5674 5675int 5676ctl_write_buffer(struct ctl_scsiio *ctsio) 5677{ 5678 struct scsi_write_buffer *cdb; 5679 struct ctl_lun *lun; --- 46 unchanged lines hidden (view full) --- 5726 ctsio->kern_sg_entries = 0; 5727 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 5728 ctsio->be_move_done = ctl_config_move_done; 5729 ctl_datamove((union ctl_io *)ctsio); 5730 5731 return (CTL_RETVAL_COMPLETE); 5732 } 5733 |
5734 ctl_set_success(ctsio); |
|
5749 ctl_done((union ctl_io *)ctsio); | 5735 ctl_done((union ctl_io *)ctsio); |
5750 | |
5751 return (CTL_RETVAL_COMPLETE); 5752} 5753 5754int 5755ctl_write_same(struct ctl_scsiio *ctsio) 5756{ 5757 struct ctl_lun *lun; 5758 struct ctl_lba_len_flags *lbalen; --- 1106 unchanged lines hidden (view full) --- 6865 (page_index->page_len * pc), 6866 page_index->page_len); 6867 data_used += page_index->page_len; 6868 } 6869 break; 6870 } 6871 } 6872 | 5736 return (CTL_RETVAL_COMPLETE); 5737} 5738 5739int 5740ctl_write_same(struct ctl_scsiio *ctsio) 5741{ 5742 struct ctl_lun *lun; 5743 struct ctl_lba_len_flags *lbalen; --- 1106 unchanged lines hidden (view full) --- 6850 (page_index->page_len * pc), 6851 page_index->page_len); 6852 data_used += page_index->page_len; 6853 } 6854 break; 6855 } 6856 } 6857 |
6873 ctsio->scsi_status = SCSI_STATUS_OK; 6874 | 6858 ctl_set_success(ctsio); |
6875 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 6876 ctsio->be_move_done = ctl_config_move_done; 6877 ctl_datamove((union ctl_io *)ctsio); | 6859 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 6860 ctsio->be_move_done = ctl_config_move_done; 6861 ctl_datamove((union ctl_io *)ctsio); |
6878 | |
6879 return (CTL_RETVAL_COMPLETE); 6880} 6881 6882int 6883ctl_lbp_log_sense_handler(struct ctl_scsiio *ctsio, 6884 struct ctl_page_index *page_index, 6885 int pc) 6886{ --- 133 unchanged lines hidden (view full) --- 7020 * Call the handler, if it exists, to update the 7021 * page to the latest values. 7022 */ 7023 if (page_index->sense_handler != NULL) 7024 page_index->sense_handler(ctsio, page_index, pc); 7025 7026 memcpy(header + 1, page_index->page_data, page_index->page_len); 7027 | 6862 return (CTL_RETVAL_COMPLETE); 6863} 6864 6865int 6866ctl_lbp_log_sense_handler(struct ctl_scsiio *ctsio, 6867 struct ctl_page_index *page_index, 6868 int pc) 6869{ --- 133 unchanged lines hidden (view full) --- 7003 * Call the handler, if it exists, to update the 7004 * page to the latest values. 7005 */ 7006 if (page_index->sense_handler != NULL) 7007 page_index->sense_handler(ctsio, page_index, pc); 7008 7009 memcpy(header + 1, page_index->page_data, page_index->page_len); 7010 |
7028 ctsio->scsi_status = SCSI_STATUS_OK; | 7011 ctl_set_success(ctsio); |
7029 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 7030 ctsio->be_move_done = ctl_config_move_done; 7031 ctl_datamove((union ctl_io *)ctsio); | 7012 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 7013 ctsio->be_move_done = ctl_config_move_done; 7014 ctl_datamove((union ctl_io *)ctsio); |
7032 | |
7033 return (CTL_RETVAL_COMPLETE); 7034} 7035 7036int 7037ctl_read_capacity(struct ctl_scsiio *ctsio) 7038{ 7039 struct scsi_read_capacity *cdb; 7040 struct scsi_read_capacity_data *data; --- 38 unchanged lines hidden (view full) --- 7079 else 7080 scsi_ulto4b(lun->be_lun->maxlba, data->addr); 7081 7082 /* 7083 * XXX KDM this may not be 512 bytes... 7084 */ 7085 scsi_ulto4b(lun->be_lun->blocksize, data->length); 7086 | 7015 return (CTL_RETVAL_COMPLETE); 7016} 7017 7018int 7019ctl_read_capacity(struct ctl_scsiio *ctsio) 7020{ 7021 struct scsi_read_capacity *cdb; 7022 struct scsi_read_capacity_data *data; --- 38 unchanged lines hidden (view full) --- 7061 else 7062 scsi_ulto4b(lun->be_lun->maxlba, data->addr); 7063 7064 /* 7065 * XXX KDM this may not be 512 bytes... 7066 */ 7067 scsi_ulto4b(lun->be_lun->blocksize, data->length); 7068 |
7087 ctsio->scsi_status = SCSI_STATUS_OK; 7088 | 7069 ctl_set_success(ctsio); |
7089 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 7090 ctsio->be_move_done = ctl_config_move_done; 7091 ctl_datamove((union ctl_io *)ctsio); | 7070 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 7071 ctsio->be_move_done = ctl_config_move_done; 7072 ctl_datamove((union ctl_io *)ctsio); |
7092 | |
7093 return (CTL_RETVAL_COMPLETE); 7094} 7095 7096int 7097ctl_read_capacity_16(struct ctl_scsiio *ctsio) 7098{ 7099 struct scsi_read_capacity_16 *cdb; 7100 struct scsi_read_capacity_data_long *data; --- 41 unchanged lines hidden (view full) --- 7142 scsi_u64to8b(lun->be_lun->maxlba, data->addr); 7143 /* XXX KDM this may not be 512 bytes... */ 7144 scsi_ulto4b(lun->be_lun->blocksize, data->length); 7145 data->prot_lbppbe = lun->be_lun->pblockexp & SRC16_LBPPBE; 7146 scsi_ulto2b(lun->be_lun->pblockoff & SRC16_LALBA_A, data->lalba_lbp); 7147 if (lun->be_lun->flags & CTL_LUN_FLAG_UNMAP) 7148 data->lalba_lbp[0] |= SRC16_LBPME | SRC16_LBPRZ; 7149 | 7073 return (CTL_RETVAL_COMPLETE); 7074} 7075 7076int 7077ctl_read_capacity_16(struct ctl_scsiio *ctsio) 7078{ 7079 struct scsi_read_capacity_16 *cdb; 7080 struct scsi_read_capacity_data_long *data; --- 41 unchanged lines hidden (view full) --- 7122 scsi_u64to8b(lun->be_lun->maxlba, data->addr); 7123 /* XXX KDM this may not be 512 bytes... */ 7124 scsi_ulto4b(lun->be_lun->blocksize, data->length); 7125 data->prot_lbppbe = lun->be_lun->pblockexp & SRC16_LBPPBE; 7126 scsi_ulto2b(lun->be_lun->pblockoff & SRC16_LALBA_A, data->lalba_lbp); 7127 if (lun->be_lun->flags & CTL_LUN_FLAG_UNMAP) 7128 data->lalba_lbp[0] |= SRC16_LBPME | SRC16_LBPRZ; 7129 |
7150 ctsio->scsi_status = SCSI_STATUS_OK; 7151 | 7130 ctl_set_success(ctsio); |
7152 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 7153 ctsio->be_move_done = ctl_config_move_done; 7154 ctl_datamove((union ctl_io *)ctsio); | 7131 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 7132 ctsio->be_move_done = ctl_config_move_done; 7133 ctl_datamove((union ctl_io *)ctsio); |
7155 | |
7156 return (CTL_RETVAL_COMPLETE); 7157} 7158 7159int 7160ctl_read_defect(struct ctl_scsiio *ctsio) 7161{ 7162 struct scsi_read_defect_data_10 *ccb10; 7163 struct scsi_read_defect_data_12 *ccb12; --- 43 unchanged lines hidden (view full) --- 7207 } else { 7208 data12 = (struct scsi_read_defect_data_hdr_12 *) 7209 ctsio->kern_data_ptr; 7210 data12->format = format; 7211 scsi_ulto2b(0, data12->generation); 7212 scsi_ulto4b(0, data12->length); 7213 } 7214 | 7134 return (CTL_RETVAL_COMPLETE); 7135} 7136 7137int 7138ctl_read_defect(struct ctl_scsiio *ctsio) 7139{ 7140 struct scsi_read_defect_data_10 *ccb10; 7141 struct scsi_read_defect_data_12 *ccb12; --- 43 unchanged lines hidden (view full) --- 7185 } else { 7186 data12 = (struct scsi_read_defect_data_hdr_12 *) 7187 ctsio->kern_data_ptr; 7188 data12->format = format; 7189 scsi_ulto2b(0, data12->generation); 7190 scsi_ulto4b(0, data12->length); 7191 } 7192 |
7215 ctsio->scsi_status = SCSI_STATUS_OK; | 7193 ctl_set_success(ctsio); |
7216 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 7217 ctsio->be_move_done = ctl_config_move_done; 7218 ctl_datamove((union ctl_io *)ctsio); 7219 return (CTL_RETVAL_COMPLETE); 7220} 7221 7222int 7223ctl_report_tagret_port_groups(struct ctl_scsiio *ctsio) --- 126 unchanged lines hidden (view full) --- 7350 pc++; 7351 } 7352 tpg_desc->target_port_count = pc; 7353 tpg_desc = (struct scsi_target_port_group_descriptor *) 7354 &tpg_desc->descriptors[pc]; 7355 } 7356 mtx_unlock(&softc->ctl_lock); 7357 | 7194 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 7195 ctsio->be_move_done = ctl_config_move_done; 7196 ctl_datamove((union ctl_io *)ctsio); 7197 return (CTL_RETVAL_COMPLETE); 7198} 7199 7200int 7201ctl_report_tagret_port_groups(struct ctl_scsiio *ctsio) --- 126 unchanged lines hidden (view full) --- 7328 pc++; 7329 } 7330 tpg_desc->target_port_count = pc; 7331 tpg_desc = (struct scsi_target_port_group_descriptor *) 7332 &tpg_desc->descriptors[pc]; 7333 } 7334 mtx_unlock(&softc->ctl_lock); 7335 |
7336 ctl_set_success(ctsio); |
|
7358 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 7359 ctsio->be_move_done = ctl_config_move_done; | 7337 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 7338 ctsio->be_move_done = ctl_config_move_done; |
7360 7361 CTL_DEBUG_PRINT(("buf = %x %x %x %x %x %x %x %x\n", 7362 ctsio->kern_data_ptr[0], ctsio->kern_data_ptr[1], 7363 ctsio->kern_data_ptr[2], ctsio->kern_data_ptr[3], 7364 ctsio->kern_data_ptr[4], ctsio->kern_data_ptr[5], 7365 ctsio->kern_data_ptr[6], ctsio->kern_data_ptr[7])); 7366 | |
7367 ctl_datamove((union ctl_io *)ctsio); 7368 return(retval); 7369} 7370 7371int 7372ctl_report_supported_opcodes(struct ctl_scsiio *ctsio) 7373{ 7374 struct ctl_lun *lun; --- 147 unchanged lines hidden (view full) --- 7522 one->cdb_usage[0] = opcode; 7523 memcpy(&one->cdb_usage[1], entry->usage, 7524 entry->length - 1); 7525 } else 7526 one->support = 1; 7527 break; 7528 } 7529 | 7339 ctl_datamove((union ctl_io *)ctsio); 7340 return(retval); 7341} 7342 7343int 7344ctl_report_supported_opcodes(struct ctl_scsiio *ctsio) 7345{ 7346 struct ctl_lun *lun; --- 147 unchanged lines hidden (view full) --- 7494 one->cdb_usage[0] = opcode; 7495 memcpy(&one->cdb_usage[1], entry->usage, 7496 entry->length - 1); 7497 } else 7498 one->support = 1; 7499 break; 7500 } 7501 |
7502 ctl_set_success(ctsio); |
|
7530 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 7531 ctsio->be_move_done = ctl_config_move_done; | 7503 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 7504 ctsio->be_move_done = ctl_config_move_done; |
7532 | |
7533 ctl_datamove((union ctl_io *)ctsio); 7534 return(retval); 7535} 7536 7537int 7538ctl_report_supported_tmf(struct ctl_scsiio *ctsio) 7539{ 7540 struct scsi_report_supported_tmf *cdb; --- 25 unchanged lines hidden (view full) --- 7566 } 7567 ctsio->kern_data_resid = 0; 7568 ctsio->kern_rel_offset = 0; 7569 7570 data = (struct scsi_report_supported_tmf_data *)ctsio->kern_data_ptr; 7571 data->byte1 |= RST_ATS | RST_ATSS | RST_CTSS | RST_LURS | RST_TRS; 7572 data->byte2 |= RST_ITNRS; 7573 | 7505 ctl_datamove((union ctl_io *)ctsio); 7506 return(retval); 7507} 7508 7509int 7510ctl_report_supported_tmf(struct ctl_scsiio *ctsio) 7511{ 7512 struct scsi_report_supported_tmf *cdb; --- 25 unchanged lines hidden (view full) --- 7538 } 7539 ctsio->kern_data_resid = 0; 7540 ctsio->kern_rel_offset = 0; 7541 7542 data = (struct scsi_report_supported_tmf_data *)ctsio->kern_data_ptr; 7543 data->byte1 |= RST_ATS | RST_ATSS | RST_CTSS | RST_LURS | RST_TRS; 7544 data->byte2 |= RST_ITNRS; 7545 |
7546 ctl_set_success(ctsio); |
|
7574 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 7575 ctsio->be_move_done = ctl_config_move_done; | 7547 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 7548 ctsio->be_move_done = ctl_config_move_done; |
7576 | |
7577 ctl_datamove((union ctl_io *)ctsio); 7578 return (retval); 7579} 7580 7581int 7582ctl_report_timestamp(struct ctl_scsiio *ctsio) 7583{ 7584 struct scsi_report_timestamp *cdb; --- 31 unchanged lines hidden (view full) --- 7616 data = (struct scsi_report_timestamp_data *)ctsio->kern_data_ptr; 7617 scsi_ulto2b(sizeof(*data) - 2, data->length); 7618 data->origin = RTS_ORIG_OUTSIDE; 7619 getmicrotime(&tv); 7620 timestamp = (int64_t)tv.tv_sec * 1000 + tv.tv_usec / 1000; 7621 scsi_ulto4b(timestamp >> 16, data->timestamp); 7622 scsi_ulto2b(timestamp & 0xffff, &data->timestamp[4]); 7623 | 7549 ctl_datamove((union ctl_io *)ctsio); 7550 return (retval); 7551} 7552 7553int 7554ctl_report_timestamp(struct ctl_scsiio *ctsio) 7555{ 7556 struct scsi_report_timestamp *cdb; --- 31 unchanged lines hidden (view full) --- 7588 data = (struct scsi_report_timestamp_data *)ctsio->kern_data_ptr; 7589 scsi_ulto2b(sizeof(*data) - 2, data->length); 7590 data->origin = RTS_ORIG_OUTSIDE; 7591 getmicrotime(&tv); 7592 timestamp = (int64_t)tv.tv_sec * 1000 + tv.tv_usec / 1000; 7593 scsi_ulto4b(timestamp >> 16, data->timestamp); 7594 scsi_ulto2b(timestamp & 0xffff, &data->timestamp[4]); 7595 |
7596 ctl_set_success(ctsio); |
|
7624 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 7625 ctsio->be_move_done = ctl_config_move_done; | 7597 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 7598 ctsio->be_move_done = ctl_config_move_done; |
7626 | |
7627 ctl_datamove((union ctl_io *)ctsio); 7628 return (retval); 7629} 7630 7631int 7632ctl_persistent_reserve_in(struct ctl_scsiio *ctsio) 7633{ 7634 struct scsi_per_res_in *cdb; --- 248 unchanged lines hidden (view full) --- 7883 * This is a bug, because we just checked for this above, 7884 * and should have returned an error. 7885 */ 7886 panic("Invalid PR type %x", cdb->action); 7887 break; /* NOTREACHED */ 7888 } 7889 mtx_unlock(&lun->lun_lock); 7890 | 7599 ctl_datamove((union ctl_io *)ctsio); 7600 return (retval); 7601} 7602 7603int 7604ctl_persistent_reserve_in(struct ctl_scsiio *ctsio) 7605{ 7606 struct scsi_per_res_in *cdb; --- 248 unchanged lines hidden (view full) --- 7855 * This is a bug, because we just checked for this above, 7856 * and should have returned an error. 7857 */ 7858 panic("Invalid PR type %x", cdb->action); 7859 break; /* NOTREACHED */ 7860 } 7861 mtx_unlock(&lun->lun_lock); 7862 |
7863 ctl_set_success(ctsio); |
|
7891 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 7892 ctsio->be_move_done = ctl_config_move_done; | 7864 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 7865 ctsio->be_move_done = ctl_config_move_done; |
7893 7894 CTL_DEBUG_PRINT(("buf = %x %x %x %x %x %x %x %x\n", 7895 ctsio->kern_data_ptr[0], ctsio->kern_data_ptr[1], 7896 ctsio->kern_data_ptr[2], ctsio->kern_data_ptr[3], 7897 ctsio->kern_data_ptr[4], ctsio->kern_data_ptr[5], 7898 ctsio->kern_data_ptr[6], ctsio->kern_data_ptr[7])); 7899 | |
7900 ctl_datamove((union ctl_io *)ctsio); | 7866 ctl_datamove((union ctl_io *)ctsio); |
7901 | |
7902 return (CTL_RETVAL_COMPLETE); 7903} 7904 7905/* 7906 * Returns 0 if ctl_persistent_reserve_out() should continue, non-zero if 7907 * it should return. 7908 */ 7909static int --- 1512 unchanged lines hidden (view full) --- 9422 * known logical units, so if the user asks for that, return none. 9423 */ 9424 scsi_ulto4b(lun_datalen - 8, lun_data->length); 9425 9426 /* 9427 * We can only return SCSI_STATUS_CHECK_COND when we can't satisfy 9428 * this request. 9429 */ | 7867 return (CTL_RETVAL_COMPLETE); 7868} 7869 7870/* 7871 * Returns 0 if ctl_persistent_reserve_out() should continue, non-zero if 7872 * it should return. 7873 */ 7874static int --- 1512 unchanged lines hidden (view full) --- 9387 * known logical units, so if the user asks for that, return none. 9388 */ 9389 scsi_ulto4b(lun_datalen - 8, lun_data->length); 9390 9391 /* 9392 * We can only return SCSI_STATUS_CHECK_COND when we can't satisfy 9393 * this request. 9394 */ |
9430 ctsio->scsi_status = SCSI_STATUS_OK; 9431 | 9395 ctl_set_success(ctsio); |
9432 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 9433 ctsio->be_move_done = ctl_config_move_done; 9434 ctl_datamove((union ctl_io *)ctsio); | 9396 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 9397 ctsio->be_move_done = ctl_config_move_done; 9398 ctl_datamove((union ctl_io *)ctsio); |
9435 | |
9436 return (retval); 9437} 9438 9439int 9440ctl_request_sense(struct ctl_scsiio *ctsio) 9441{ 9442 struct scsi_request_sense *cdb; 9443 struct scsi_sense_data *sense_ptr; --- 97 unchanged lines hidden (view full) --- 9541 9542 /* 9543 * We already have a pending error, return it. 9544 */ 9545 if (have_error != 0) { 9546 /* 9547 * We report the SCSI status as OK, since the status of the 9548 * request sense command itself is OK. | 9399 return (retval); 9400} 9401 9402int 9403ctl_request_sense(struct ctl_scsiio *ctsio) 9404{ 9405 struct scsi_request_sense *cdb; 9406 struct scsi_sense_data *sense_ptr; --- 97 unchanged lines hidden (view full) --- 9504 9505 /* 9506 * We already have a pending error, return it. 9507 */ 9508 if (have_error != 0) { 9509 /* 9510 * We report the SCSI status as OK, since the status of the 9511 * request sense command itself is OK. |
9549 */ 9550 ctsio->scsi_status = SCSI_STATUS_OK; 9551 9552 /* | |
9553 * We report 0 for the sense length, because we aren't doing 9554 * autosense in this case. We're reporting sense as 9555 * parameter data. 9556 */ | 9512 * We report 0 for the sense length, because we aren't doing 9513 * autosense in this case. We're reporting sense as 9514 * parameter data. 9515 */ |
9557 ctsio->sense_len = 0; | 9516 ctl_set_success(ctsio); |
9558 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 9559 ctsio->be_move_done = ctl_config_move_done; 9560 ctl_datamove((union ctl_io *)ctsio); | 9517 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 9518 ctsio->be_move_done = ctl_config_move_done; 9519 ctl_datamove((union ctl_io *)ctsio); |
9561 | |
9562 return (CTL_RETVAL_COMPLETE); 9563 } 9564 9565no_sense: 9566 9567 /* 9568 * No sense information to report, so we report that everything is 9569 * okay. 9570 */ 9571 ctl_set_sense_data(sense_ptr, 9572 lun, 9573 sense_format, 9574 /*current_error*/ 1, 9575 /*sense_key*/ SSD_KEY_NO_SENSE, 9576 /*asc*/ 0x00, 9577 /*ascq*/ 0x00, 9578 SSD_ELEM_NONE); 9579 | 9520 return (CTL_RETVAL_COMPLETE); 9521 } 9522 9523no_sense: 9524 9525 /* 9526 * No sense information to report, so we report that everything is 9527 * okay. 9528 */ 9529 ctl_set_sense_data(sense_ptr, 9530 lun, 9531 sense_format, 9532 /*current_error*/ 1, 9533 /*sense_key*/ SSD_KEY_NO_SENSE, 9534 /*asc*/ 0x00, 9535 /*ascq*/ 0x00, 9536 SSD_ELEM_NONE); 9537 |
9580 ctsio->scsi_status = SCSI_STATUS_OK; 9581 | |
9582 /* 9583 * We report 0 for the sense length, because we aren't doing 9584 * autosense in this case. We're reporting sense as parameter data. 9585 */ | 9538 /* 9539 * We report 0 for the sense length, because we aren't doing 9540 * autosense in this case. We're reporting sense as parameter data. 9541 */ |
9586 ctsio->sense_len = 0; | 9542 ctl_set_success(ctsio); |
9587 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 9588 ctsio->be_move_done = ctl_config_move_done; 9589 ctl_datamove((union ctl_io *)ctsio); | 9543 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 9544 ctsio->be_move_done = ctl_config_move_done; 9545 ctl_datamove((union ctl_io *)ctsio); |
9590 | |
9591 return (CTL_RETVAL_COMPLETE); 9592} 9593 9594int 9595ctl_tur(struct ctl_scsiio *ctsio) 9596{ 9597 9598 CTL_DEBUG_PRINT(("ctl_tur\n")); --- 68 unchanged lines hidden (view full) --- 9667 pages->page_list[6] = SVPD_SCSI_TPC; 9668 /* Block limits */ 9669 pages->page_list[7] = SVPD_BLOCK_LIMITS; 9670 /* Block Device Characteristics */ 9671 pages->page_list[8] = SVPD_BDC; 9672 /* Logical Block Provisioning */ 9673 pages->page_list[9] = SVPD_LBP; 9674 | 9546 return (CTL_RETVAL_COMPLETE); 9547} 9548 9549int 9550ctl_tur(struct ctl_scsiio *ctsio) 9551{ 9552 9553 CTL_DEBUG_PRINT(("ctl_tur\n")); --- 68 unchanged lines hidden (view full) --- 9622 pages->page_list[6] = SVPD_SCSI_TPC; 9623 /* Block limits */ 9624 pages->page_list[7] = SVPD_BLOCK_LIMITS; 9625 /* Block Device Characteristics */ 9626 pages->page_list[8] = SVPD_BDC; 9627 /* Logical Block Provisioning */ 9628 pages->page_list[9] = SVPD_LBP; 9629 |
9675 ctsio->scsi_status = SCSI_STATUS_OK; 9676 | 9630 ctl_set_success(ctsio); |
9677 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 9678 ctsio->be_move_done = ctl_config_move_done; 9679 ctl_datamove((union ctl_io *)ctsio); | 9631 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 9632 ctsio->be_move_done = ctl_config_move_done; 9633 ctl_datamove((union ctl_io *)ctsio); |
9680 | |
9681 return (CTL_RETVAL_COMPLETE); 9682} 9683 9684static int 9685ctl_inquiry_evpd_serial(struct ctl_scsiio *ctsio, int alloc_len) 9686{ 9687 struct scsi_vpd_unit_serial_number *sn_ptr; 9688 struct ctl_lun *lun; --- 34 unchanged lines hidden (view full) --- 9723 * If we don't have a LUN, we just leave the serial number as 9724 * all spaces. 9725 */ 9726 if (lun != NULL) { 9727 strncpy((char *)sn_ptr->serial_num, 9728 (char *)lun->be_lun->serial_num, CTL_SN_LEN); 9729 } else 9730 memset(sn_ptr->serial_num, 0x20, CTL_SN_LEN); | 9634 return (CTL_RETVAL_COMPLETE); 9635} 9636 9637static int 9638ctl_inquiry_evpd_serial(struct ctl_scsiio *ctsio, int alloc_len) 9639{ 9640 struct scsi_vpd_unit_serial_number *sn_ptr; 9641 struct ctl_lun *lun; --- 34 unchanged lines hidden (view full) --- 9676 * If we don't have a LUN, we just leave the serial number as 9677 * all spaces. 9678 */ 9679 if (lun != NULL) { 9680 strncpy((char *)sn_ptr->serial_num, 9681 (char *)lun->be_lun->serial_num, CTL_SN_LEN); 9682 } else 9683 memset(sn_ptr->serial_num, 0x20, CTL_SN_LEN); |
9731 ctsio->scsi_status = SCSI_STATUS_OK; | |
9732 | 9684 |
9685 ctl_set_success(ctsio); |
|
9733 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 9734 ctsio->be_move_done = ctl_config_move_done; 9735 ctl_datamove((union ctl_io *)ctsio); | 9686 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 9687 ctsio->be_move_done = ctl_config_move_done; 9688 ctl_datamove((union ctl_io *)ctsio); |
9736 | |
9737 return (CTL_RETVAL_COMPLETE); 9738} 9739 9740 9741static int 9742ctl_inquiry_evpd_eid(struct ctl_scsiio *ctsio, int alloc_len) 9743{ 9744 struct scsi_vpd_extended_inquiry_data *eid_ptr; --- 29 unchanged lines hidden (view full) --- 9774 lun->be_lun->lun_type; 9775 else 9776 eid_ptr->device = (SID_QUAL_LU_OFFLINE << 5) | T_DIRECT; 9777 eid_ptr->page_code = SVPD_EXTENDED_INQUIRY_DATA; 9778 eid_ptr->page_length = data_len - 4; 9779 eid_ptr->flags2 = SVPD_EID_HEADSUP | SVPD_EID_ORDSUP | SVPD_EID_SIMPSUP; 9780 eid_ptr->flags3 = SVPD_EID_V_SUP; 9781 | 9689 return (CTL_RETVAL_COMPLETE); 9690} 9691 9692 9693static int 9694ctl_inquiry_evpd_eid(struct ctl_scsiio *ctsio, int alloc_len) 9695{ 9696 struct scsi_vpd_extended_inquiry_data *eid_ptr; --- 29 unchanged lines hidden (view full) --- 9726 lun->be_lun->lun_type; 9727 else 9728 eid_ptr->device = (SID_QUAL_LU_OFFLINE << 5) | T_DIRECT; 9729 eid_ptr->page_code = SVPD_EXTENDED_INQUIRY_DATA; 9730 eid_ptr->page_length = data_len - 4; 9731 eid_ptr->flags2 = SVPD_EID_HEADSUP | SVPD_EID_ORDSUP | SVPD_EID_SIMPSUP; 9732 eid_ptr->flags3 = SVPD_EID_V_SUP; 9733 |
9782 ctsio->scsi_status = SCSI_STATUS_OK; | 9734 ctl_set_success(ctsio); |
9783 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 9784 ctsio->be_move_done = ctl_config_move_done; 9785 ctl_datamove((union ctl_io *)ctsio); | 9735 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 9736 ctsio->be_move_done = ctl_config_move_done; 9737 ctl_datamove((union ctl_io *)ctsio); |
9786 | |
9787 return (CTL_RETVAL_COMPLETE); 9788} 9789 9790static int 9791ctl_inquiry_evpd_mpp(struct ctl_scsiio *ctsio, int alloc_len) 9792{ 9793 struct scsi_vpd_mode_page_policy *mpp_ptr; 9794 struct ctl_lun *lun; --- 31 unchanged lines hidden (view full) --- 9826 else 9827 mpp_ptr->device = (SID_QUAL_LU_OFFLINE << 5) | T_DIRECT; 9828 mpp_ptr->page_code = SVPD_MODE_PAGE_POLICY; 9829 scsi_ulto2b(data_len - 4, mpp_ptr->page_length); 9830 mpp_ptr->descr[0].page_code = 0x3f; 9831 mpp_ptr->descr[0].subpage_code = 0xff; 9832 mpp_ptr->descr[0].policy = SVPD_MPP_SHARED; 9833 | 9738 return (CTL_RETVAL_COMPLETE); 9739} 9740 9741static int 9742ctl_inquiry_evpd_mpp(struct ctl_scsiio *ctsio, int alloc_len) 9743{ 9744 struct scsi_vpd_mode_page_policy *mpp_ptr; 9745 struct ctl_lun *lun; --- 31 unchanged lines hidden (view full) --- 9777 else 9778 mpp_ptr->device = (SID_QUAL_LU_OFFLINE << 5) | T_DIRECT; 9779 mpp_ptr->page_code = SVPD_MODE_PAGE_POLICY; 9780 scsi_ulto2b(data_len - 4, mpp_ptr->page_length); 9781 mpp_ptr->descr[0].page_code = 0x3f; 9782 mpp_ptr->descr[0].subpage_code = 0xff; 9783 mpp_ptr->descr[0].policy = SVPD_MPP_SHARED; 9784 |
9834 ctsio->scsi_status = SCSI_STATUS_OK; | 9785 ctl_set_success(ctsio); |
9835 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 9836 ctsio->be_move_done = ctl_config_move_done; 9837 ctl_datamove((union ctl_io *)ctsio); | 9786 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 9787 ctsio->be_move_done = ctl_config_move_done; 9788 ctl_datamove((union ctl_io *)ctsio); |
9838 | |
9839 return (CTL_RETVAL_COMPLETE); 9840} 9841 9842static int 9843ctl_inquiry_evpd_devid(struct ctl_scsiio *ctsio, int alloc_len) 9844{ 9845 struct scsi_vpd_device_id *devid_ptr; 9846 struct scsi_vpd_id_descriptor *desc; --- 101 unchanged lines hidden (view full) --- 9948 9949 /* 9950 * This is for the Target identifier 9951 */ 9952 if (port->target_devid) { 9953 memcpy(desc, port->target_devid->data, port->target_devid->len); 9954 } 9955 | 9789 return (CTL_RETVAL_COMPLETE); 9790} 9791 9792static int 9793ctl_inquiry_evpd_devid(struct ctl_scsiio *ctsio, int alloc_len) 9794{ 9795 struct scsi_vpd_device_id *devid_ptr; 9796 struct scsi_vpd_id_descriptor *desc; --- 101 unchanged lines hidden (view full) --- 9898 9899 /* 9900 * This is for the Target identifier 9901 */ 9902 if (port->target_devid) { 9903 memcpy(desc, port->target_devid->data, port->target_devid->len); 9904 } 9905 |
9956 ctsio->scsi_status = SCSI_STATUS_OK; | 9906 ctl_set_success(ctsio); |
9957 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 9958 ctsio->be_move_done = ctl_config_move_done; 9959 ctl_datamove((union ctl_io *)ctsio); | 9907 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 9908 ctsio->be_move_done = ctl_config_move_done; 9909 ctl_datamove((union ctl_io *)ctsio); |
9960 | |
9961 return (CTL_RETVAL_COMPLETE); 9962} 9963 9964static int 9965ctl_inquiry_evpd_scsi_ports(struct ctl_scsiio *ctsio, int alloc_len) 9966{ 9967 struct ctl_softc *softc = control_softc; 9968 struct scsi_vpd_scsi_ports *sp; --- 94 unchanged lines hidden (view full) --- 10063 id_len = 0; 10064 scsi_ulto2b(id_len, pdc->target_port_descriptors_length); 10065 pd = (struct scsi_vpd_port_designation *) 10066 ((uint8_t *)pdc->target_port_descriptors + id_len); 10067 } 10068 } 10069 mtx_unlock(&softc->ctl_lock); 10070 | 9910 return (CTL_RETVAL_COMPLETE); 9911} 9912 9913static int 9914ctl_inquiry_evpd_scsi_ports(struct ctl_scsiio *ctsio, int alloc_len) 9915{ 9916 struct ctl_softc *softc = control_softc; 9917 struct scsi_vpd_scsi_ports *sp; --- 94 unchanged lines hidden (view full) --- 10012 id_len = 0; 10013 scsi_ulto2b(id_len, pdc->target_port_descriptors_length); 10014 pd = (struct scsi_vpd_port_designation *) 10015 ((uint8_t *)pdc->target_port_descriptors + id_len); 10016 } 10017 } 10018 mtx_unlock(&softc->ctl_lock); 10019 |
10071 ctsio->scsi_status = SCSI_STATUS_OK; | 10020 ctl_set_success(ctsio); |
10072 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 10073 ctsio->be_move_done = ctl_config_move_done; 10074 ctl_datamove((union ctl_io *)ctsio); | 10021 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 10022 ctsio->be_move_done = ctl_config_move_done; 10023 ctl_datamove((union ctl_io *)ctsio); |
10075 | |
10076 return (CTL_RETVAL_COMPLETE); 10077} 10078 10079static int 10080ctl_inquiry_evpd_block_limits(struct ctl_scsiio *ctsio, int alloc_len) 10081{ 10082 struct scsi_vpd_block_limits *bl_ptr; 10083 struct ctl_lun *lun; --- 48 unchanged lines hidden (view full) --- 10132 } 10133 scsi_ulto4b(lun->be_lun->atomicblock, 10134 bl_ptr->max_atomic_transfer_length); 10135 scsi_ulto4b(0, bl_ptr->atomic_alignment); 10136 scsi_ulto4b(0, bl_ptr->atomic_transfer_length_granularity); 10137 } 10138 scsi_u64to8b(UINT64_MAX, bl_ptr->max_write_same_length); 10139 | 10024 return (CTL_RETVAL_COMPLETE); 10025} 10026 10027static int 10028ctl_inquiry_evpd_block_limits(struct ctl_scsiio *ctsio, int alloc_len) 10029{ 10030 struct scsi_vpd_block_limits *bl_ptr; 10031 struct ctl_lun *lun; --- 48 unchanged lines hidden (view full) --- 10080 } 10081 scsi_ulto4b(lun->be_lun->atomicblock, 10082 bl_ptr->max_atomic_transfer_length); 10083 scsi_ulto4b(0, bl_ptr->atomic_alignment); 10084 scsi_ulto4b(0, bl_ptr->atomic_transfer_length_granularity); 10085 } 10086 scsi_u64to8b(UINT64_MAX, bl_ptr->max_write_same_length); 10087 |
10140 ctsio->scsi_status = SCSI_STATUS_OK; | 10088 ctl_set_success(ctsio); |
10141 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 10142 ctsio->be_move_done = ctl_config_move_done; 10143 ctl_datamove((union ctl_io *)ctsio); | 10089 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 10090 ctsio->be_move_done = ctl_config_move_done; 10091 ctl_datamove((union ctl_io *)ctsio); |
10144 | |
10145 return (CTL_RETVAL_COMPLETE); 10146} 10147 10148static int 10149ctl_inquiry_evpd_bdc(struct ctl_scsiio *ctsio, int alloc_len) 10150{ 10151 struct scsi_vpd_block_device_characteristics *bdc_ptr; 10152 struct ctl_lun *lun; --- 40 unchanged lines hidden (view full) --- 10193 if (lun != NULL && 10194 (value = ctl_get_opt(&lun->be_lun->options, "formfactor")) != NULL) 10195 i = strtol(value, NULL, 0); 10196 else 10197 i = 0; 10198 bdc_ptr->wab_wac_ff = (i & 0x0f); 10199 bdc_ptr->flags = SVPD_FUAB | SVPD_VBULS; 10200 | 10092 return (CTL_RETVAL_COMPLETE); 10093} 10094 10095static int 10096ctl_inquiry_evpd_bdc(struct ctl_scsiio *ctsio, int alloc_len) 10097{ 10098 struct scsi_vpd_block_device_characteristics *bdc_ptr; 10099 struct ctl_lun *lun; --- 40 unchanged lines hidden (view full) --- 10140 if (lun != NULL && 10141 (value = ctl_get_opt(&lun->be_lun->options, "formfactor")) != NULL) 10142 i = strtol(value, NULL, 0); 10143 else 10144 i = 0; 10145 bdc_ptr->wab_wac_ff = (i & 0x0f); 10146 bdc_ptr->flags = SVPD_FUAB | SVPD_VBULS; 10147 |
10201 ctsio->scsi_status = SCSI_STATUS_OK; | 10148 ctl_set_success(ctsio); |
10202 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 10203 ctsio->be_move_done = ctl_config_move_done; 10204 ctl_datamove((union ctl_io *)ctsio); | 10149 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 10150 ctsio->be_move_done = ctl_config_move_done; 10151 ctl_datamove((union ctl_io *)ctsio); |
10205 | |
10206 return (CTL_RETVAL_COMPLETE); 10207} 10208 10209static int 10210ctl_inquiry_evpd_lbp(struct ctl_scsiio *ctsio, int alloc_len) 10211{ 10212 struct scsi_vpd_logical_block_prov *lbp_ptr; 10213 struct ctl_lun *lun; --- 32 unchanged lines hidden (view full) --- 10246 scsi_ulto2b(sizeof(*lbp_ptr) - 4, lbp_ptr->page_length); 10247 if (lun != NULL && lun->be_lun->flags & CTL_LUN_FLAG_UNMAP) { 10248 lbp_ptr->threshold_exponent = CTL_LBP_EXPONENT; 10249 lbp_ptr->flags = SVPD_LBP_UNMAP | SVPD_LBP_WS16 | 10250 SVPD_LBP_WS10 | SVPD_LBP_RZ | SVPD_LBP_ANC_SUP; 10251 lbp_ptr->prov_type = SVPD_LBP_THIN; 10252 } 10253 | 10152 return (CTL_RETVAL_COMPLETE); 10153} 10154 10155static int 10156ctl_inquiry_evpd_lbp(struct ctl_scsiio *ctsio, int alloc_len) 10157{ 10158 struct scsi_vpd_logical_block_prov *lbp_ptr; 10159 struct ctl_lun *lun; --- 32 unchanged lines hidden (view full) --- 10192 scsi_ulto2b(sizeof(*lbp_ptr) - 4, lbp_ptr->page_length); 10193 if (lun != NULL && lun->be_lun->flags & CTL_LUN_FLAG_UNMAP) { 10194 lbp_ptr->threshold_exponent = CTL_LBP_EXPONENT; 10195 lbp_ptr->flags = SVPD_LBP_UNMAP | SVPD_LBP_WS16 | 10196 SVPD_LBP_WS10 | SVPD_LBP_RZ | SVPD_LBP_ANC_SUP; 10197 lbp_ptr->prov_type = SVPD_LBP_THIN; 10198 } 10199 |
10254 ctsio->scsi_status = SCSI_STATUS_OK; | 10200 ctl_set_success(ctsio); |
10255 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 10256 ctsio->be_move_done = ctl_config_move_done; 10257 ctl_datamove((union ctl_io *)ctsio); | 10201 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 10202 ctsio->be_move_done = ctl_config_move_done; 10203 ctl_datamove((union ctl_io *)ctsio); |
10258 | |
10259 return (CTL_RETVAL_COMPLETE); 10260} 10261 10262static int 10263ctl_inquiry_evpd(struct ctl_scsiio *ctsio) 10264{ 10265 struct scsi_inquiry *cdb; 10266 int alloc_len, retval; --- 283 unchanged lines hidden (view full) --- 10550 scsi_ulto2b(0x0600, inq_ptr->version4); 10551 break; 10552 case T_PROCESSOR: 10553 default: 10554 break; 10555 } 10556 } 10557 | 10204 return (CTL_RETVAL_COMPLETE); 10205} 10206 10207static int 10208ctl_inquiry_evpd(struct ctl_scsiio *ctsio) 10209{ 10210 struct scsi_inquiry *cdb; 10211 int alloc_len, retval; --- 283 unchanged lines hidden (view full) --- 10495 scsi_ulto2b(0x0600, inq_ptr->version4); 10496 break; 10497 case T_PROCESSOR: 10498 default: 10499 break; 10500 } 10501 } 10502 |
10558 ctsio->scsi_status = SCSI_STATUS_OK; | 10503 ctl_set_success(ctsio); |
10559 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 10560 ctsio->be_move_done = ctl_config_move_done; 10561 ctl_datamove((union ctl_io *)ctsio); 10562 return (CTL_RETVAL_COMPLETE); 10563} 10564 10565int 10566ctl_inquiry(struct ctl_scsiio *ctsio) --- 2954 unchanged lines hidden (view full) --- 13521 } 13522 13523 mtx_lock(&lun->lun_lock); 13524 13525 /* 13526 * Check to see if we have any errors to inject here. We only 13527 * inject errors for commands that don't already have errors set. 13528 */ | 10504 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 10505 ctsio->be_move_done = ctl_config_move_done; 10506 ctl_datamove((union ctl_io *)ctsio); 10507 return (CTL_RETVAL_COMPLETE); 10508} 10509 10510int 10511ctl_inquiry(struct ctl_scsiio *ctsio) --- 2954 unchanged lines hidden (view full) --- 13466 } 13467 13468 mtx_lock(&lun->lun_lock); 13469 13470 /* 13471 * Check to see if we have any errors to inject here. We only 13472 * inject errors for commands that don't already have errors set. 13473 */ |
13529 if ((STAILQ_FIRST(&lun->error_list) != NULL) 13530 && ((io->io_hdr.status & CTL_STATUS_MASK) == CTL_SUCCESS)) | 13474 if ((STAILQ_FIRST(&lun->error_list) != NULL) && 13475 ((io->io_hdr.status & CTL_STATUS_MASK) == CTL_SUCCESS) && 13476 ((io->io_hdr.flags & CTL_FLAG_STATUS_SENT) == 0)) |
13531 ctl_inject_error(lun, io); 13532 13533 /* 13534 * XXX KDM how do we treat commands that aren't completed 13535 * successfully? 13536 * 13537 * XXX KDM should we also track I/O latency? 13538 */ --- 693 unchanged lines hidden --- | 13477 ctl_inject_error(lun, io); 13478 13479 /* 13480 * XXX KDM how do we treat commands that aren't completed 13481 * successfully? 13482 * 13483 * XXX KDM should we also track I/O latency? 13484 */ --- 693 unchanged lines hidden --- |