ctl.c (275879) | ctl.c (275881) |
---|---|
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: stable/10/sys/cam/ctl/ctl.c 275879 2014-12-18 08:23:04Z mav $"); | 45__FBSDID("$FreeBSD: stable/10/sys/cam/ctl/ctl.c 275881 2014-12-18 08:25:00Z 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> --- 4939 unchanged lines hidden (view full) --- 4993 * Backend "memory move is complete" callback for requests that never 4994 * make it down to say RAIDCore's configuration code. 4995 */ 4996int 4997ctl_config_move_done(union ctl_io *io) 4998{ 4999 int retval; 5000 | 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> --- 4939 unchanged lines hidden (view full) --- 4993 * Backend "memory move is complete" callback for requests that never 4994 * make it down to say RAIDCore's configuration code. 4995 */ 4996int 4997ctl_config_move_done(union ctl_io *io) 4998{ 4999 int retval; 5000 |
5001 retval = CTL_RETVAL_COMPLETE; 5002 5003 | |
5004 CTL_DEBUG_PRINT(("ctl_config_move_done\n")); | 5001 CTL_DEBUG_PRINT(("ctl_config_move_done\n")); |
5005 /* 5006 * XXX KDM this shouldn't happen, but what if it does? 5007 */ 5008 if (io->io_hdr.io_type != CTL_IO_SCSI) 5009 panic("I/O type isn't CTL_IO_SCSI!"); | 5002 KASSERT(io->io_hdr.io_type == CTL_IO_SCSI, 5003 ("Config I/O type isn't CTL_IO_SCSI (%d)!", io->io_hdr.io_type)); |
5010 | 5004 |
5011 if ((io->io_hdr.port_status == 0) 5012 && ((io->io_hdr.flags & CTL_FLAG_ABORT) == 0) 5013 && ((io->io_hdr.status & CTL_STATUS_MASK) == CTL_STATUS_NONE)) 5014 io->io_hdr.status = CTL_SUCCESS; 5015 else if ((io->io_hdr.port_status != 0) 5016 && ((io->io_hdr.flags & CTL_FLAG_ABORT) == 0) 5017 && ((io->io_hdr.status & CTL_STATUS_MASK) == CTL_STATUS_NONE)){ | 5005 if ((io->io_hdr.port_status != 0) && 5006 ((io->io_hdr.status & CTL_STATUS_MASK) == CTL_STATUS_NONE || 5007 (io->io_hdr.status & CTL_STATUS_MASK) == CTL_SUCCESS)) { |
5018 /* 5019 * For hardware error sense keys, the sense key 5020 * specific value is defined to be a retry count, 5021 * but we use it to pass back an internal FETD 5022 * error code. XXX KDM Hopefully the FETD is only 5023 * using 16 bits for an error code, since that's 5024 * all the space we have in the sks field. 5025 */ 5026 ctl_set_internal_failure(&io->scsiio, 5027 /*sks_valid*/ 1, 5028 /*retry_count*/ 5029 io->io_hdr.port_status); | 5008 /* 5009 * For hardware error sense keys, the sense key 5010 * specific value is defined to be a retry count, 5011 * but we use it to pass back an internal FETD 5012 * error code. XXX KDM Hopefully the FETD is only 5013 * using 16 bits for an error code, since that's 5014 * all the space we have in the sks field. 5015 */ 5016 ctl_set_internal_failure(&io->scsiio, 5017 /*sks_valid*/ 1, 5018 /*retry_count*/ 5019 io->io_hdr.port_status); |
5030 if (io->io_hdr.flags & CTL_FLAG_ALLOCATED) 5031 free(io->scsiio.kern_data_ptr, M_CTL); 5032 ctl_done(io); 5033 goto bailout; | |
5034 } 5035 | 5020 } 5021 |
5036 if (((io->io_hdr.flags & CTL_FLAG_DATA_MASK) == CTL_FLAG_DATA_IN) 5037 || ((io->io_hdr.status & CTL_STATUS_MASK) != CTL_SUCCESS) 5038 || ((io->io_hdr.flags & CTL_FLAG_ABORT) != 0)) { | 5022 if (((io->io_hdr.flags & CTL_FLAG_DATA_MASK) == CTL_FLAG_DATA_IN) || 5023 ((io->io_hdr.status & CTL_STATUS_MASK) != CTL_STATUS_NONE && 5024 (io->io_hdr.status & CTL_STATUS_MASK) != CTL_SUCCESS) || 5025 ((io->io_hdr.flags & CTL_FLAG_ABORT) != 0)) { |
5039 /* 5040 * XXX KDM just assuming a single pointer here, and not a 5041 * S/G list. If we start using S/G lists for config data, 5042 * we'll need to know how to clean them up here as well. 5043 */ 5044 if (io->io_hdr.flags & CTL_FLAG_ALLOCATED) 5045 free(io->scsiio.kern_data_ptr, M_CTL); | 5026 /* 5027 * XXX KDM just assuming a single pointer here, and not a 5028 * S/G list. If we start using S/G lists for config data, 5029 * we'll need to know how to clean them up here as well. 5030 */ 5031 if (io->io_hdr.flags & CTL_FLAG_ALLOCATED) 5032 free(io->scsiio.kern_data_ptr, M_CTL); |
5046 /* Hopefully the user has already set the status... */ | |
5047 ctl_done(io); | 5033 ctl_done(io); |
5034 retval = CTL_RETVAL_COMPLETE; |
|
5048 } else { 5049 /* 5050 * XXX KDM now we need to continue data movement. Some 5051 * options: 5052 * - call ctl_scsiio() again? We don't do this for data 5053 * writes, because for those at least we know ahead of 5054 * time where the write will go and how long it is. For 5055 * config writes, though, that information is largely --- 6 unchanged lines hidden (view full) --- 5062 ctl_data_print(io); 5063 5064 /* 5065 * XXX KDM call ctl_scsiio() again for now, and check flag 5066 * bits to see whether we're allocated or not. 5067 */ 5068 retval = ctl_scsiio(&io->scsiio); 5069 } | 5035 } else { 5036 /* 5037 * XXX KDM now we need to continue data movement. Some 5038 * options: 5039 * - call ctl_scsiio() again? We don't do this for data 5040 * writes, because for those at least we know ahead of 5041 * time where the write will go and how long it is. For 5042 * config writes, though, that information is largely --- 6 unchanged lines hidden (view full) --- 5049 ctl_data_print(io); 5050 5051 /* 5052 * XXX KDM call ctl_scsiio() again for now, and check flag 5053 * bits to see whether we're allocated or not. 5054 */ 5055 retval = ctl_scsiio(&io->scsiio); 5056 } |
5070bailout: | |
5071 return (retval); 5072} 5073 5074/* 5075 * This gets called by a backend driver when it is done with a 5076 * data_submit method. 5077 */ 5078void --- 129 unchanged lines hidden (view full) --- 5208 * released, though, by the initiator who made it or by one of 5209 * several reset type events. 5210 */ 5211 if ((lun->flags & CTL_LUN_RESERVED) && (lun->res_idx == residx)) 5212 lun->flags &= ~CTL_LUN_RESERVED; 5213 5214 mtx_unlock(&lun->lun_lock); 5215 | 5057 return (retval); 5058} 5059 5060/* 5061 * This gets called by a backend driver when it is done with a 5062 * data_submit method. 5063 */ 5064void --- 129 unchanged lines hidden (view full) --- 5194 * released, though, by the initiator who made it or by one of 5195 * several reset type events. 5196 */ 5197 if ((lun->flags & CTL_LUN_RESERVED) && (lun->res_idx == residx)) 5198 lun->flags &= ~CTL_LUN_RESERVED; 5199 5200 mtx_unlock(&lun->lun_lock); 5201 |
5216 ctl_set_success(ctsio); 5217 | |
5218 if (ctsio->io_hdr.flags & CTL_FLAG_ALLOCATED) { 5219 free(ctsio->kern_data_ptr, M_CTL); 5220 ctsio->io_hdr.flags &= ~CTL_FLAG_ALLOCATED; 5221 } 5222 | 5202 if (ctsio->io_hdr.flags & CTL_FLAG_ALLOCATED) { 5203 free(ctsio->kern_data_ptr, M_CTL); 5204 ctsio->io_hdr.flags &= ~CTL_FLAG_ALLOCATED; 5205 } 5206 |
5207 ctl_set_success(ctsio); |
|
5223 ctl_done((union ctl_io *)ctsio); 5224 return (CTL_RETVAL_COMPLETE); 5225} 5226 5227int 5228ctl_scsi_reserve(struct ctl_scsiio *ctsio) 5229{ 5230 int extent, thirdparty, longid; --- 447 unchanged lines hidden (view full) --- 5678 } 5679 ctsio->kern_data_ptr = lun->write_buffer + buffer_offset; 5680 } 5681 ctsio->kern_data_len = len; 5682 ctsio->kern_total_len = len; 5683 ctsio->kern_data_resid = 0; 5684 ctsio->kern_rel_offset = 0; 5685 ctsio->kern_sg_entries = 0; | 5208 ctl_done((union ctl_io *)ctsio); 5209 return (CTL_RETVAL_COMPLETE); 5210} 5211 5212int 5213ctl_scsi_reserve(struct ctl_scsiio *ctsio) 5214{ 5215 int extent, thirdparty, longid; --- 447 unchanged lines hidden (view full) --- 5663 } 5664 ctsio->kern_data_ptr = lun->write_buffer + buffer_offset; 5665 } 5666 ctsio->kern_data_len = len; 5667 ctsio->kern_total_len = len; 5668 ctsio->kern_data_resid = 0; 5669 ctsio->kern_rel_offset = 0; 5670 ctsio->kern_sg_entries = 0; |
5671 ctl_set_success(ctsio); |
|
5686 ctsio->be_move_done = ctl_config_move_done; 5687 ctl_datamove((union ctl_io *)ctsio); | 5672 ctsio->be_move_done = ctl_config_move_done; 5673 ctl_datamove((union ctl_io *)ctsio); |
5688 | |
5689 return (CTL_RETVAL_COMPLETE); 5690} 5691 5692int 5693ctl_write_buffer(struct ctl_scsiio *ctsio) 5694{ 5695 struct scsi_write_buffer *cdb; 5696 struct ctl_lun *lun; --- 46 unchanged lines hidden (view full) --- 5743 ctsio->kern_sg_entries = 0; 5744 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 5745 ctsio->be_move_done = ctl_config_move_done; 5746 ctl_datamove((union ctl_io *)ctsio); 5747 5748 return (CTL_RETVAL_COMPLETE); 5749 } 5750 | 5674 return (CTL_RETVAL_COMPLETE); 5675} 5676 5677int 5678ctl_write_buffer(struct ctl_scsiio *ctsio) 5679{ 5680 struct scsi_write_buffer *cdb; 5681 struct ctl_lun *lun; --- 46 unchanged lines hidden (view full) --- 5728 ctsio->kern_sg_entries = 0; 5729 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 5730 ctsio->be_move_done = ctl_config_move_done; 5731 ctl_datamove((union ctl_io *)ctsio); 5732 5733 return (CTL_RETVAL_COMPLETE); 5734 } 5735 |
5736 ctl_set_success(ctsio); |
|
5751 ctl_done((union ctl_io *)ctsio); | 5737 ctl_done((union ctl_io *)ctsio); |
5752 | |
5753 return (CTL_RETVAL_COMPLETE); 5754} 5755 5756int 5757ctl_write_same(struct ctl_scsiio *ctsio) 5758{ 5759 struct ctl_lun *lun; 5760 struct ctl_lba_len_flags *lbalen; --- 1112 unchanged lines hidden (view full) --- 6873 (page_index->page_len * pc), 6874 page_index->page_len); 6875 data_used += page_index->page_len; 6876 } 6877 break; 6878 } 6879 } 6880 | 5738 return (CTL_RETVAL_COMPLETE); 5739} 5740 5741int 5742ctl_write_same(struct ctl_scsiio *ctsio) 5743{ 5744 struct ctl_lun *lun; 5745 struct ctl_lba_len_flags *lbalen; --- 1112 unchanged lines hidden (view full) --- 6858 (page_index->page_len * pc), 6859 page_index->page_len); 6860 data_used += page_index->page_len; 6861 } 6862 break; 6863 } 6864 } 6865 |
6881 ctsio->scsi_status = SCSI_STATUS_OK; 6882 | 6866 ctl_set_success(ctsio); |
6883 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 6884 ctsio->be_move_done = ctl_config_move_done; 6885 ctl_datamove((union ctl_io *)ctsio); | 6867 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 6868 ctsio->be_move_done = ctl_config_move_done; 6869 ctl_datamove((union ctl_io *)ctsio); |
6886 | |
6887 return (CTL_RETVAL_COMPLETE); 6888} 6889 6890int 6891ctl_lbp_log_sense_handler(struct ctl_scsiio *ctsio, 6892 struct ctl_page_index *page_index, 6893 int pc) 6894{ --- 133 unchanged lines hidden (view full) --- 7028 * Call the handler, if it exists, to update the 7029 * page to the latest values. 7030 */ 7031 if (page_index->sense_handler != NULL) 7032 page_index->sense_handler(ctsio, page_index, pc); 7033 7034 memcpy(header + 1, page_index->page_data, page_index->page_len); 7035 | 6870 return (CTL_RETVAL_COMPLETE); 6871} 6872 6873int 6874ctl_lbp_log_sense_handler(struct ctl_scsiio *ctsio, 6875 struct ctl_page_index *page_index, 6876 int pc) 6877{ --- 133 unchanged lines hidden (view full) --- 7011 * Call the handler, if it exists, to update the 7012 * page to the latest values. 7013 */ 7014 if (page_index->sense_handler != NULL) 7015 page_index->sense_handler(ctsio, page_index, pc); 7016 7017 memcpy(header + 1, page_index->page_data, page_index->page_len); 7018 |
7036 ctsio->scsi_status = SCSI_STATUS_OK; | 7019 ctl_set_success(ctsio); |
7037 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 7038 ctsio->be_move_done = ctl_config_move_done; 7039 ctl_datamove((union ctl_io *)ctsio); | 7020 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 7021 ctsio->be_move_done = ctl_config_move_done; 7022 ctl_datamove((union ctl_io *)ctsio); |
7040 | |
7041 return (CTL_RETVAL_COMPLETE); 7042} 7043 7044int 7045ctl_read_capacity(struct ctl_scsiio *ctsio) 7046{ 7047 struct scsi_read_capacity *cdb; 7048 struct scsi_read_capacity_data *data; --- 38 unchanged lines hidden (view full) --- 7087 else 7088 scsi_ulto4b(lun->be_lun->maxlba, data->addr); 7089 7090 /* 7091 * XXX KDM this may not be 512 bytes... 7092 */ 7093 scsi_ulto4b(lun->be_lun->blocksize, data->length); 7094 | 7023 return (CTL_RETVAL_COMPLETE); 7024} 7025 7026int 7027ctl_read_capacity(struct ctl_scsiio *ctsio) 7028{ 7029 struct scsi_read_capacity *cdb; 7030 struct scsi_read_capacity_data *data; --- 38 unchanged lines hidden (view full) --- 7069 else 7070 scsi_ulto4b(lun->be_lun->maxlba, data->addr); 7071 7072 /* 7073 * XXX KDM this may not be 512 bytes... 7074 */ 7075 scsi_ulto4b(lun->be_lun->blocksize, data->length); 7076 |
7095 ctsio->scsi_status = SCSI_STATUS_OK; 7096 | 7077 ctl_set_success(ctsio); |
7097 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 7098 ctsio->be_move_done = ctl_config_move_done; 7099 ctl_datamove((union ctl_io *)ctsio); | 7078 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 7079 ctsio->be_move_done = ctl_config_move_done; 7080 ctl_datamove((union ctl_io *)ctsio); |
7100 | |
7101 return (CTL_RETVAL_COMPLETE); 7102} 7103 7104int 7105ctl_read_capacity_16(struct ctl_scsiio *ctsio) 7106{ 7107 struct scsi_read_capacity_16 *cdb; 7108 struct scsi_read_capacity_data_long *data; --- 41 unchanged lines hidden (view full) --- 7150 scsi_u64to8b(lun->be_lun->maxlba, data->addr); 7151 /* XXX KDM this may not be 512 bytes... */ 7152 scsi_ulto4b(lun->be_lun->blocksize, data->length); 7153 data->prot_lbppbe = lun->be_lun->pblockexp & SRC16_LBPPBE; 7154 scsi_ulto2b(lun->be_lun->pblockoff & SRC16_LALBA_A, data->lalba_lbp); 7155 if (lun->be_lun->flags & CTL_LUN_FLAG_UNMAP) 7156 data->lalba_lbp[0] |= SRC16_LBPME | SRC16_LBPRZ; 7157 | 7081 return (CTL_RETVAL_COMPLETE); 7082} 7083 7084int 7085ctl_read_capacity_16(struct ctl_scsiio *ctsio) 7086{ 7087 struct scsi_read_capacity_16 *cdb; 7088 struct scsi_read_capacity_data_long *data; --- 41 unchanged lines hidden (view full) --- 7130 scsi_u64to8b(lun->be_lun->maxlba, data->addr); 7131 /* XXX KDM this may not be 512 bytes... */ 7132 scsi_ulto4b(lun->be_lun->blocksize, data->length); 7133 data->prot_lbppbe = lun->be_lun->pblockexp & SRC16_LBPPBE; 7134 scsi_ulto2b(lun->be_lun->pblockoff & SRC16_LALBA_A, data->lalba_lbp); 7135 if (lun->be_lun->flags & CTL_LUN_FLAG_UNMAP) 7136 data->lalba_lbp[0] |= SRC16_LBPME | SRC16_LBPRZ; 7137 |
7158 ctsio->scsi_status = SCSI_STATUS_OK; 7159 | 7138 ctl_set_success(ctsio); |
7160 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 7161 ctsio->be_move_done = ctl_config_move_done; 7162 ctl_datamove((union ctl_io *)ctsio); | 7139 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 7140 ctsio->be_move_done = ctl_config_move_done; 7141 ctl_datamove((union ctl_io *)ctsio); |
7163 | |
7164 return (CTL_RETVAL_COMPLETE); 7165} 7166 7167int 7168ctl_read_defect(struct ctl_scsiio *ctsio) 7169{ 7170 struct scsi_read_defect_data_10 *ccb10; 7171 struct scsi_read_defect_data_12 *ccb12; --- 43 unchanged lines hidden (view full) --- 7215 } else { 7216 data12 = (struct scsi_read_defect_data_hdr_12 *) 7217 ctsio->kern_data_ptr; 7218 data12->format = format; 7219 scsi_ulto2b(0, data12->generation); 7220 scsi_ulto4b(0, data12->length); 7221 } 7222 | 7142 return (CTL_RETVAL_COMPLETE); 7143} 7144 7145int 7146ctl_read_defect(struct ctl_scsiio *ctsio) 7147{ 7148 struct scsi_read_defect_data_10 *ccb10; 7149 struct scsi_read_defect_data_12 *ccb12; --- 43 unchanged lines hidden (view full) --- 7193 } else { 7194 data12 = (struct scsi_read_defect_data_hdr_12 *) 7195 ctsio->kern_data_ptr; 7196 data12->format = format; 7197 scsi_ulto2b(0, data12->generation); 7198 scsi_ulto4b(0, data12->length); 7199 } 7200 |
7223 ctsio->scsi_status = SCSI_STATUS_OK; | 7201 ctl_set_success(ctsio); |
7224 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 7225 ctsio->be_move_done = ctl_config_move_done; 7226 ctl_datamove((union ctl_io *)ctsio); 7227 return (CTL_RETVAL_COMPLETE); 7228} 7229 7230int 7231ctl_report_tagret_port_groups(struct ctl_scsiio *ctsio) --- 126 unchanged lines hidden (view full) --- 7358 pc++; 7359 } 7360 tpg_desc->target_port_count = pc; 7361 tpg_desc = (struct scsi_target_port_group_descriptor *) 7362 &tpg_desc->descriptors[pc]; 7363 } 7364 mtx_unlock(&softc->ctl_lock); 7365 | 7202 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 7203 ctsio->be_move_done = ctl_config_move_done; 7204 ctl_datamove((union ctl_io *)ctsio); 7205 return (CTL_RETVAL_COMPLETE); 7206} 7207 7208int 7209ctl_report_tagret_port_groups(struct ctl_scsiio *ctsio) --- 126 unchanged lines hidden (view full) --- 7336 pc++; 7337 } 7338 tpg_desc->target_port_count = pc; 7339 tpg_desc = (struct scsi_target_port_group_descriptor *) 7340 &tpg_desc->descriptors[pc]; 7341 } 7342 mtx_unlock(&softc->ctl_lock); 7343 |
7344 ctl_set_success(ctsio); |
|
7366 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 7367 ctsio->be_move_done = ctl_config_move_done; | 7345 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 7346 ctsio->be_move_done = ctl_config_move_done; |
7368 7369 CTL_DEBUG_PRINT(("buf = %x %x %x %x %x %x %x %x\n", 7370 ctsio->kern_data_ptr[0], ctsio->kern_data_ptr[1], 7371 ctsio->kern_data_ptr[2], ctsio->kern_data_ptr[3], 7372 ctsio->kern_data_ptr[4], ctsio->kern_data_ptr[5], 7373 ctsio->kern_data_ptr[6], ctsio->kern_data_ptr[7])); 7374 | |
7375 ctl_datamove((union ctl_io *)ctsio); 7376 return(retval); 7377} 7378 7379int 7380ctl_report_supported_opcodes(struct ctl_scsiio *ctsio) 7381{ 7382 struct ctl_lun *lun; --- 147 unchanged lines hidden (view full) --- 7530 one->cdb_usage[0] = opcode; 7531 memcpy(&one->cdb_usage[1], entry->usage, 7532 entry->length - 1); 7533 } else 7534 one->support = 1; 7535 break; 7536 } 7537 | 7347 ctl_datamove((union ctl_io *)ctsio); 7348 return(retval); 7349} 7350 7351int 7352ctl_report_supported_opcodes(struct ctl_scsiio *ctsio) 7353{ 7354 struct ctl_lun *lun; --- 147 unchanged lines hidden (view full) --- 7502 one->cdb_usage[0] = opcode; 7503 memcpy(&one->cdb_usage[1], entry->usage, 7504 entry->length - 1); 7505 } else 7506 one->support = 1; 7507 break; 7508 } 7509 |
7510 ctl_set_success(ctsio); |
|
7538 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 7539 ctsio->be_move_done = ctl_config_move_done; | 7511 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 7512 ctsio->be_move_done = ctl_config_move_done; |
7540 | |
7541 ctl_datamove((union ctl_io *)ctsio); 7542 return(retval); 7543} 7544 7545int 7546ctl_report_supported_tmf(struct ctl_scsiio *ctsio) 7547{ 7548 struct scsi_report_supported_tmf *cdb; --- 25 unchanged lines hidden (view full) --- 7574 } 7575 ctsio->kern_data_resid = 0; 7576 ctsio->kern_rel_offset = 0; 7577 7578 data = (struct scsi_report_supported_tmf_data *)ctsio->kern_data_ptr; 7579 data->byte1 |= RST_ATS | RST_ATSS | RST_CTSS | RST_LURS | RST_TRS; 7580 data->byte2 |= RST_ITNRS; 7581 | 7513 ctl_datamove((union ctl_io *)ctsio); 7514 return(retval); 7515} 7516 7517int 7518ctl_report_supported_tmf(struct ctl_scsiio *ctsio) 7519{ 7520 struct scsi_report_supported_tmf *cdb; --- 25 unchanged lines hidden (view full) --- 7546 } 7547 ctsio->kern_data_resid = 0; 7548 ctsio->kern_rel_offset = 0; 7549 7550 data = (struct scsi_report_supported_tmf_data *)ctsio->kern_data_ptr; 7551 data->byte1 |= RST_ATS | RST_ATSS | RST_CTSS | RST_LURS | RST_TRS; 7552 data->byte2 |= RST_ITNRS; 7553 |
7554 ctl_set_success(ctsio); |
|
7582 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 7583 ctsio->be_move_done = ctl_config_move_done; | 7555 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 7556 ctsio->be_move_done = ctl_config_move_done; |
7584 | |
7585 ctl_datamove((union ctl_io *)ctsio); 7586 return (retval); 7587} 7588 7589int 7590ctl_report_timestamp(struct ctl_scsiio *ctsio) 7591{ 7592 struct scsi_report_timestamp *cdb; --- 31 unchanged lines hidden (view full) --- 7624 data = (struct scsi_report_timestamp_data *)ctsio->kern_data_ptr; 7625 scsi_ulto2b(sizeof(*data) - 2, data->length); 7626 data->origin = RTS_ORIG_OUTSIDE; 7627 getmicrotime(&tv); 7628 timestamp = (int64_t)tv.tv_sec * 1000 + tv.tv_usec / 1000; 7629 scsi_ulto4b(timestamp >> 16, data->timestamp); 7630 scsi_ulto2b(timestamp & 0xffff, &data->timestamp[4]); 7631 | 7557 ctl_datamove((union ctl_io *)ctsio); 7558 return (retval); 7559} 7560 7561int 7562ctl_report_timestamp(struct ctl_scsiio *ctsio) 7563{ 7564 struct scsi_report_timestamp *cdb; --- 31 unchanged lines hidden (view full) --- 7596 data = (struct scsi_report_timestamp_data *)ctsio->kern_data_ptr; 7597 scsi_ulto2b(sizeof(*data) - 2, data->length); 7598 data->origin = RTS_ORIG_OUTSIDE; 7599 getmicrotime(&tv); 7600 timestamp = (int64_t)tv.tv_sec * 1000 + tv.tv_usec / 1000; 7601 scsi_ulto4b(timestamp >> 16, data->timestamp); 7602 scsi_ulto2b(timestamp & 0xffff, &data->timestamp[4]); 7603 |
7604 ctl_set_success(ctsio); |
|
7632 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 7633 ctsio->be_move_done = ctl_config_move_done; | 7605 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 7606 ctsio->be_move_done = ctl_config_move_done; |
7634 | |
7635 ctl_datamove((union ctl_io *)ctsio); 7636 return (retval); 7637} 7638 7639int 7640ctl_persistent_reserve_in(struct ctl_scsiio *ctsio) 7641{ 7642 struct scsi_per_res_in *cdb; --- 248 unchanged lines hidden (view full) --- 7891 * This is a bug, because we just checked for this above, 7892 * and should have returned an error. 7893 */ 7894 panic("Invalid PR type %x", cdb->action); 7895 break; /* NOTREACHED */ 7896 } 7897 mtx_unlock(&lun->lun_lock); 7898 | 7607 ctl_datamove((union ctl_io *)ctsio); 7608 return (retval); 7609} 7610 7611int 7612ctl_persistent_reserve_in(struct ctl_scsiio *ctsio) 7613{ 7614 struct scsi_per_res_in *cdb; --- 248 unchanged lines hidden (view full) --- 7863 * This is a bug, because we just checked for this above, 7864 * and should have returned an error. 7865 */ 7866 panic("Invalid PR type %x", cdb->action); 7867 break; /* NOTREACHED */ 7868 } 7869 mtx_unlock(&lun->lun_lock); 7870 |
7871 ctl_set_success(ctsio); |
|
7899 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 7900 ctsio->be_move_done = ctl_config_move_done; | 7872 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 7873 ctsio->be_move_done = ctl_config_move_done; |
7901 7902 CTL_DEBUG_PRINT(("buf = %x %x %x %x %x %x %x %x\n", 7903 ctsio->kern_data_ptr[0], ctsio->kern_data_ptr[1], 7904 ctsio->kern_data_ptr[2], ctsio->kern_data_ptr[3], 7905 ctsio->kern_data_ptr[4], ctsio->kern_data_ptr[5], 7906 ctsio->kern_data_ptr[6], ctsio->kern_data_ptr[7])); 7907 | |
7908 ctl_datamove((union ctl_io *)ctsio); | 7874 ctl_datamove((union ctl_io *)ctsio); |
7909 | |
7910 return (CTL_RETVAL_COMPLETE); 7911} 7912 7913/* 7914 * Returns 0 if ctl_persistent_reserve_out() should continue, non-zero if 7915 * it should return. 7916 */ 7917static int --- 1512 unchanged lines hidden (view full) --- 9430 * known logical units, so if the user asks for that, return none. 9431 */ 9432 scsi_ulto4b(lun_datalen - 8, lun_data->length); 9433 9434 /* 9435 * We can only return SCSI_STATUS_CHECK_COND when we can't satisfy 9436 * this request. 9437 */ | 7875 return (CTL_RETVAL_COMPLETE); 7876} 7877 7878/* 7879 * Returns 0 if ctl_persistent_reserve_out() should continue, non-zero if 7880 * it should return. 7881 */ 7882static int --- 1512 unchanged lines hidden (view full) --- 9395 * known logical units, so if the user asks for that, return none. 9396 */ 9397 scsi_ulto4b(lun_datalen - 8, lun_data->length); 9398 9399 /* 9400 * We can only return SCSI_STATUS_CHECK_COND when we can't satisfy 9401 * this request. 9402 */ |
9438 ctsio->scsi_status = SCSI_STATUS_OK; 9439 | 9403 ctl_set_success(ctsio); |
9440 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 9441 ctsio->be_move_done = ctl_config_move_done; 9442 ctl_datamove((union ctl_io *)ctsio); | 9404 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 9405 ctsio->be_move_done = ctl_config_move_done; 9406 ctl_datamove((union ctl_io *)ctsio); |
9443 | |
9444 return (retval); 9445} 9446 9447int 9448ctl_request_sense(struct ctl_scsiio *ctsio) 9449{ 9450 struct scsi_request_sense *cdb; 9451 struct scsi_sense_data *sense_ptr; --- 97 unchanged lines hidden (view full) --- 9549 9550 /* 9551 * We already have a pending error, return it. 9552 */ 9553 if (have_error != 0) { 9554 /* 9555 * We report the SCSI status as OK, since the status of the 9556 * request sense command itself is OK. | 9407 return (retval); 9408} 9409 9410int 9411ctl_request_sense(struct ctl_scsiio *ctsio) 9412{ 9413 struct scsi_request_sense *cdb; 9414 struct scsi_sense_data *sense_ptr; --- 97 unchanged lines hidden (view full) --- 9512 9513 /* 9514 * We already have a pending error, return it. 9515 */ 9516 if (have_error != 0) { 9517 /* 9518 * We report the SCSI status as OK, since the status of the 9519 * request sense command itself is OK. |
9557 */ 9558 ctsio->scsi_status = SCSI_STATUS_OK; 9559 9560 /* | |
9561 * We report 0 for the sense length, because we aren't doing 9562 * autosense in this case. We're reporting sense as 9563 * parameter data. 9564 */ | 9520 * We report 0 for the sense length, because we aren't doing 9521 * autosense in this case. We're reporting sense as 9522 * parameter data. 9523 */ |
9565 ctsio->sense_len = 0; | 9524 ctl_set_success(ctsio); |
9566 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 9567 ctsio->be_move_done = ctl_config_move_done; 9568 ctl_datamove((union ctl_io *)ctsio); | 9525 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 9526 ctsio->be_move_done = ctl_config_move_done; 9527 ctl_datamove((union ctl_io *)ctsio); |
9569 | |
9570 return (CTL_RETVAL_COMPLETE); 9571 } 9572 9573no_sense: 9574 9575 /* 9576 * No sense information to report, so we report that everything is 9577 * okay. 9578 */ 9579 ctl_set_sense_data(sense_ptr, 9580 lun, 9581 sense_format, 9582 /*current_error*/ 1, 9583 /*sense_key*/ SSD_KEY_NO_SENSE, 9584 /*asc*/ 0x00, 9585 /*ascq*/ 0x00, 9586 SSD_ELEM_NONE); 9587 | 9528 return (CTL_RETVAL_COMPLETE); 9529 } 9530 9531no_sense: 9532 9533 /* 9534 * No sense information to report, so we report that everything is 9535 * okay. 9536 */ 9537 ctl_set_sense_data(sense_ptr, 9538 lun, 9539 sense_format, 9540 /*current_error*/ 1, 9541 /*sense_key*/ SSD_KEY_NO_SENSE, 9542 /*asc*/ 0x00, 9543 /*ascq*/ 0x00, 9544 SSD_ELEM_NONE); 9545 |
9588 ctsio->scsi_status = SCSI_STATUS_OK; 9589 | |
9590 /* 9591 * We report 0 for the sense length, because we aren't doing 9592 * autosense in this case. We're reporting sense as parameter data. 9593 */ | 9546 /* 9547 * We report 0 for the sense length, because we aren't doing 9548 * autosense in this case. We're reporting sense as parameter data. 9549 */ |
9594 ctsio->sense_len = 0; | 9550 ctl_set_success(ctsio); |
9595 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 9596 ctsio->be_move_done = ctl_config_move_done; 9597 ctl_datamove((union ctl_io *)ctsio); | 9551 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 9552 ctsio->be_move_done = ctl_config_move_done; 9553 ctl_datamove((union ctl_io *)ctsio); |
9598 | |
9599 return (CTL_RETVAL_COMPLETE); 9600} 9601 9602int 9603ctl_tur(struct ctl_scsiio *ctsio) 9604{ 9605 9606 CTL_DEBUG_PRINT(("ctl_tur\n")); --- 68 unchanged lines hidden (view full) --- 9675 pages->page_list[6] = SVPD_SCSI_TPC; 9676 /* Block limits */ 9677 pages->page_list[7] = SVPD_BLOCK_LIMITS; 9678 /* Block Device Characteristics */ 9679 pages->page_list[8] = SVPD_BDC; 9680 /* Logical Block Provisioning */ 9681 pages->page_list[9] = SVPD_LBP; 9682 | 9554 return (CTL_RETVAL_COMPLETE); 9555} 9556 9557int 9558ctl_tur(struct ctl_scsiio *ctsio) 9559{ 9560 9561 CTL_DEBUG_PRINT(("ctl_tur\n")); --- 68 unchanged lines hidden (view full) --- 9630 pages->page_list[6] = SVPD_SCSI_TPC; 9631 /* Block limits */ 9632 pages->page_list[7] = SVPD_BLOCK_LIMITS; 9633 /* Block Device Characteristics */ 9634 pages->page_list[8] = SVPD_BDC; 9635 /* Logical Block Provisioning */ 9636 pages->page_list[9] = SVPD_LBP; 9637 |
9683 ctsio->scsi_status = SCSI_STATUS_OK; 9684 | 9638 ctl_set_success(ctsio); |
9685 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 9686 ctsio->be_move_done = ctl_config_move_done; 9687 ctl_datamove((union ctl_io *)ctsio); | 9639 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 9640 ctsio->be_move_done = ctl_config_move_done; 9641 ctl_datamove((union ctl_io *)ctsio); |
9688 | |
9689 return (CTL_RETVAL_COMPLETE); 9690} 9691 9692static int 9693ctl_inquiry_evpd_serial(struct ctl_scsiio *ctsio, int alloc_len) 9694{ 9695 struct scsi_vpd_unit_serial_number *sn_ptr; 9696 struct ctl_lun *lun; --- 34 unchanged lines hidden (view full) --- 9731 * If we don't have a LUN, we just leave the serial number as 9732 * all spaces. 9733 */ 9734 if (lun != NULL) { 9735 strncpy((char *)sn_ptr->serial_num, 9736 (char *)lun->be_lun->serial_num, CTL_SN_LEN); 9737 } else 9738 memset(sn_ptr->serial_num, 0x20, CTL_SN_LEN); | 9642 return (CTL_RETVAL_COMPLETE); 9643} 9644 9645static int 9646ctl_inquiry_evpd_serial(struct ctl_scsiio *ctsio, int alloc_len) 9647{ 9648 struct scsi_vpd_unit_serial_number *sn_ptr; 9649 struct ctl_lun *lun; --- 34 unchanged lines hidden (view full) --- 9684 * If we don't have a LUN, we just leave the serial number as 9685 * all spaces. 9686 */ 9687 if (lun != NULL) { 9688 strncpy((char *)sn_ptr->serial_num, 9689 (char *)lun->be_lun->serial_num, CTL_SN_LEN); 9690 } else 9691 memset(sn_ptr->serial_num, 0x20, CTL_SN_LEN); |
9739 ctsio->scsi_status = SCSI_STATUS_OK; | |
9740 | 9692 |
9693 ctl_set_success(ctsio); |
|
9741 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 9742 ctsio->be_move_done = ctl_config_move_done; 9743 ctl_datamove((union ctl_io *)ctsio); | 9694 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 9695 ctsio->be_move_done = ctl_config_move_done; 9696 ctl_datamove((union ctl_io *)ctsio); |
9744 | |
9745 return (CTL_RETVAL_COMPLETE); 9746} 9747 9748 9749static int 9750ctl_inquiry_evpd_eid(struct ctl_scsiio *ctsio, int alloc_len) 9751{ 9752 struct scsi_vpd_extended_inquiry_data *eid_ptr; --- 29 unchanged lines hidden (view full) --- 9782 lun->be_lun->lun_type; 9783 else 9784 eid_ptr->device = (SID_QUAL_LU_OFFLINE << 5) | T_DIRECT; 9785 eid_ptr->page_code = SVPD_EXTENDED_INQUIRY_DATA; 9786 eid_ptr->page_length = data_len - 4; 9787 eid_ptr->flags2 = SVPD_EID_HEADSUP | SVPD_EID_ORDSUP | SVPD_EID_SIMPSUP; 9788 eid_ptr->flags3 = SVPD_EID_V_SUP; 9789 | 9697 return (CTL_RETVAL_COMPLETE); 9698} 9699 9700 9701static int 9702ctl_inquiry_evpd_eid(struct ctl_scsiio *ctsio, int alloc_len) 9703{ 9704 struct scsi_vpd_extended_inquiry_data *eid_ptr; --- 29 unchanged lines hidden (view full) --- 9734 lun->be_lun->lun_type; 9735 else 9736 eid_ptr->device = (SID_QUAL_LU_OFFLINE << 5) | T_DIRECT; 9737 eid_ptr->page_code = SVPD_EXTENDED_INQUIRY_DATA; 9738 eid_ptr->page_length = data_len - 4; 9739 eid_ptr->flags2 = SVPD_EID_HEADSUP | SVPD_EID_ORDSUP | SVPD_EID_SIMPSUP; 9740 eid_ptr->flags3 = SVPD_EID_V_SUP; 9741 |
9790 ctsio->scsi_status = SCSI_STATUS_OK; | 9742 ctl_set_success(ctsio); |
9791 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 9792 ctsio->be_move_done = ctl_config_move_done; 9793 ctl_datamove((union ctl_io *)ctsio); | 9743 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 9744 ctsio->be_move_done = ctl_config_move_done; 9745 ctl_datamove((union ctl_io *)ctsio); |
9794 | |
9795 return (CTL_RETVAL_COMPLETE); 9796} 9797 9798static int 9799ctl_inquiry_evpd_mpp(struct ctl_scsiio *ctsio, int alloc_len) 9800{ 9801 struct scsi_vpd_mode_page_policy *mpp_ptr; 9802 struct ctl_lun *lun; --- 31 unchanged lines hidden (view full) --- 9834 else 9835 mpp_ptr->device = (SID_QUAL_LU_OFFLINE << 5) | T_DIRECT; 9836 mpp_ptr->page_code = SVPD_MODE_PAGE_POLICY; 9837 scsi_ulto2b(data_len - 4, mpp_ptr->page_length); 9838 mpp_ptr->descr[0].page_code = 0x3f; 9839 mpp_ptr->descr[0].subpage_code = 0xff; 9840 mpp_ptr->descr[0].policy = SVPD_MPP_SHARED; 9841 | 9746 return (CTL_RETVAL_COMPLETE); 9747} 9748 9749static int 9750ctl_inquiry_evpd_mpp(struct ctl_scsiio *ctsio, int alloc_len) 9751{ 9752 struct scsi_vpd_mode_page_policy *mpp_ptr; 9753 struct ctl_lun *lun; --- 31 unchanged lines hidden (view full) --- 9785 else 9786 mpp_ptr->device = (SID_QUAL_LU_OFFLINE << 5) | T_DIRECT; 9787 mpp_ptr->page_code = SVPD_MODE_PAGE_POLICY; 9788 scsi_ulto2b(data_len - 4, mpp_ptr->page_length); 9789 mpp_ptr->descr[0].page_code = 0x3f; 9790 mpp_ptr->descr[0].subpage_code = 0xff; 9791 mpp_ptr->descr[0].policy = SVPD_MPP_SHARED; 9792 |
9842 ctsio->scsi_status = SCSI_STATUS_OK; | 9793 ctl_set_success(ctsio); |
9843 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 9844 ctsio->be_move_done = ctl_config_move_done; 9845 ctl_datamove((union ctl_io *)ctsio); | 9794 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 9795 ctsio->be_move_done = ctl_config_move_done; 9796 ctl_datamove((union ctl_io *)ctsio); |
9846 | |
9847 return (CTL_RETVAL_COMPLETE); 9848} 9849 9850static int 9851ctl_inquiry_evpd_devid(struct ctl_scsiio *ctsio, int alloc_len) 9852{ 9853 struct scsi_vpd_device_id *devid_ptr; 9854 struct scsi_vpd_id_descriptor *desc; --- 101 unchanged lines hidden (view full) --- 9956 9957 /* 9958 * This is for the Target identifier 9959 */ 9960 if (port->target_devid) { 9961 memcpy(desc, port->target_devid->data, port->target_devid->len); 9962 } 9963 | 9797 return (CTL_RETVAL_COMPLETE); 9798} 9799 9800static int 9801ctl_inquiry_evpd_devid(struct ctl_scsiio *ctsio, int alloc_len) 9802{ 9803 struct scsi_vpd_device_id *devid_ptr; 9804 struct scsi_vpd_id_descriptor *desc; --- 101 unchanged lines hidden (view full) --- 9906 9907 /* 9908 * This is for the Target identifier 9909 */ 9910 if (port->target_devid) { 9911 memcpy(desc, port->target_devid->data, port->target_devid->len); 9912 } 9913 |
9964 ctsio->scsi_status = SCSI_STATUS_OK; | 9914 ctl_set_success(ctsio); |
9965 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 9966 ctsio->be_move_done = ctl_config_move_done; 9967 ctl_datamove((union ctl_io *)ctsio); | 9915 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 9916 ctsio->be_move_done = ctl_config_move_done; 9917 ctl_datamove((union ctl_io *)ctsio); |
9968 | |
9969 return (CTL_RETVAL_COMPLETE); 9970} 9971 9972static int 9973ctl_inquiry_evpd_scsi_ports(struct ctl_scsiio *ctsio, int alloc_len) 9974{ 9975 struct ctl_softc *softc = control_softc; 9976 struct scsi_vpd_scsi_ports *sp; --- 94 unchanged lines hidden (view full) --- 10071 id_len = 0; 10072 scsi_ulto2b(id_len, pdc->target_port_descriptors_length); 10073 pd = (struct scsi_vpd_port_designation *) 10074 ((uint8_t *)pdc->target_port_descriptors + id_len); 10075 } 10076 } 10077 mtx_unlock(&softc->ctl_lock); 10078 | 9918 return (CTL_RETVAL_COMPLETE); 9919} 9920 9921static int 9922ctl_inquiry_evpd_scsi_ports(struct ctl_scsiio *ctsio, int alloc_len) 9923{ 9924 struct ctl_softc *softc = control_softc; 9925 struct scsi_vpd_scsi_ports *sp; --- 94 unchanged lines hidden (view full) --- 10020 id_len = 0; 10021 scsi_ulto2b(id_len, pdc->target_port_descriptors_length); 10022 pd = (struct scsi_vpd_port_designation *) 10023 ((uint8_t *)pdc->target_port_descriptors + id_len); 10024 } 10025 } 10026 mtx_unlock(&softc->ctl_lock); 10027 |
10079 ctsio->scsi_status = SCSI_STATUS_OK; | 10028 ctl_set_success(ctsio); |
10080 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 10081 ctsio->be_move_done = ctl_config_move_done; 10082 ctl_datamove((union ctl_io *)ctsio); | 10029 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 10030 ctsio->be_move_done = ctl_config_move_done; 10031 ctl_datamove((union ctl_io *)ctsio); |
10083 | |
10084 return (CTL_RETVAL_COMPLETE); 10085} 10086 10087static int 10088ctl_inquiry_evpd_block_limits(struct ctl_scsiio *ctsio, int alloc_len) 10089{ 10090 struct scsi_vpd_block_limits *bl_ptr; 10091 struct ctl_lun *lun; --- 48 unchanged lines hidden (view full) --- 10140 } 10141 scsi_ulto4b(lun->be_lun->atomicblock, 10142 bl_ptr->max_atomic_transfer_length); 10143 scsi_ulto4b(0, bl_ptr->atomic_alignment); 10144 scsi_ulto4b(0, bl_ptr->atomic_transfer_length_granularity); 10145 } 10146 scsi_u64to8b(UINT64_MAX, bl_ptr->max_write_same_length); 10147 | 10032 return (CTL_RETVAL_COMPLETE); 10033} 10034 10035static int 10036ctl_inquiry_evpd_block_limits(struct ctl_scsiio *ctsio, int alloc_len) 10037{ 10038 struct scsi_vpd_block_limits *bl_ptr; 10039 struct ctl_lun *lun; --- 48 unchanged lines hidden (view full) --- 10088 } 10089 scsi_ulto4b(lun->be_lun->atomicblock, 10090 bl_ptr->max_atomic_transfer_length); 10091 scsi_ulto4b(0, bl_ptr->atomic_alignment); 10092 scsi_ulto4b(0, bl_ptr->atomic_transfer_length_granularity); 10093 } 10094 scsi_u64to8b(UINT64_MAX, bl_ptr->max_write_same_length); 10095 |
10148 ctsio->scsi_status = SCSI_STATUS_OK; | 10096 ctl_set_success(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); | 10097 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 10098 ctsio->be_move_done = ctl_config_move_done; 10099 ctl_datamove((union ctl_io *)ctsio); |
10152 | |
10153 return (CTL_RETVAL_COMPLETE); 10154} 10155 10156static int 10157ctl_inquiry_evpd_bdc(struct ctl_scsiio *ctsio, int alloc_len) 10158{ 10159 struct scsi_vpd_block_device_characteristics *bdc_ptr; 10160 struct ctl_lun *lun; --- 40 unchanged lines hidden (view full) --- 10201 if (lun != NULL && 10202 (value = ctl_get_opt(&lun->be_lun->options, "formfactor")) != NULL) 10203 i = strtol(value, NULL, 0); 10204 else 10205 i = 0; 10206 bdc_ptr->wab_wac_ff = (i & 0x0f); 10207 bdc_ptr->flags = SVPD_FUAB | SVPD_VBULS; 10208 | 10100 return (CTL_RETVAL_COMPLETE); 10101} 10102 10103static int 10104ctl_inquiry_evpd_bdc(struct ctl_scsiio *ctsio, int alloc_len) 10105{ 10106 struct scsi_vpd_block_device_characteristics *bdc_ptr; 10107 struct ctl_lun *lun; --- 40 unchanged lines hidden (view full) --- 10148 if (lun != NULL && 10149 (value = ctl_get_opt(&lun->be_lun->options, "formfactor")) != NULL) 10150 i = strtol(value, NULL, 0); 10151 else 10152 i = 0; 10153 bdc_ptr->wab_wac_ff = (i & 0x0f); 10154 bdc_ptr->flags = SVPD_FUAB | SVPD_VBULS; 10155 |
10209 ctsio->scsi_status = SCSI_STATUS_OK; | 10156 ctl_set_success(ctsio); |
10210 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 10211 ctsio->be_move_done = ctl_config_move_done; 10212 ctl_datamove((union ctl_io *)ctsio); | 10157 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 10158 ctsio->be_move_done = ctl_config_move_done; 10159 ctl_datamove((union ctl_io *)ctsio); |
10213 | |
10214 return (CTL_RETVAL_COMPLETE); 10215} 10216 10217static int 10218ctl_inquiry_evpd_lbp(struct ctl_scsiio *ctsio, int alloc_len) 10219{ 10220 struct scsi_vpd_logical_block_prov *lbp_ptr; 10221 struct ctl_lun *lun; --- 32 unchanged lines hidden (view full) --- 10254 scsi_ulto2b(sizeof(*lbp_ptr) - 4, lbp_ptr->page_length); 10255 if (lun != NULL && lun->be_lun->flags & CTL_LUN_FLAG_UNMAP) { 10256 lbp_ptr->threshold_exponent = CTL_LBP_EXPONENT; 10257 lbp_ptr->flags = SVPD_LBP_UNMAP | SVPD_LBP_WS16 | 10258 SVPD_LBP_WS10 | SVPD_LBP_RZ | SVPD_LBP_ANC_SUP; 10259 lbp_ptr->prov_type = SVPD_LBP_THIN; 10260 } 10261 | 10160 return (CTL_RETVAL_COMPLETE); 10161} 10162 10163static int 10164ctl_inquiry_evpd_lbp(struct ctl_scsiio *ctsio, int alloc_len) 10165{ 10166 struct scsi_vpd_logical_block_prov *lbp_ptr; 10167 struct ctl_lun *lun; --- 32 unchanged lines hidden (view full) --- 10200 scsi_ulto2b(sizeof(*lbp_ptr) - 4, lbp_ptr->page_length); 10201 if (lun != NULL && lun->be_lun->flags & CTL_LUN_FLAG_UNMAP) { 10202 lbp_ptr->threshold_exponent = CTL_LBP_EXPONENT; 10203 lbp_ptr->flags = SVPD_LBP_UNMAP | SVPD_LBP_WS16 | 10204 SVPD_LBP_WS10 | SVPD_LBP_RZ | SVPD_LBP_ANC_SUP; 10205 lbp_ptr->prov_type = SVPD_LBP_THIN; 10206 } 10207 |
10262 ctsio->scsi_status = SCSI_STATUS_OK; | 10208 ctl_set_success(ctsio); |
10263 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 10264 ctsio->be_move_done = ctl_config_move_done; 10265 ctl_datamove((union ctl_io *)ctsio); | 10209 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 10210 ctsio->be_move_done = ctl_config_move_done; 10211 ctl_datamove((union ctl_io *)ctsio); |
10266 | |
10267 return (CTL_RETVAL_COMPLETE); 10268} 10269 10270static int 10271ctl_inquiry_evpd(struct ctl_scsiio *ctsio) 10272{ 10273 struct scsi_inquiry *cdb; 10274 int alloc_len, retval; --- 283 unchanged lines hidden (view full) --- 10558 scsi_ulto2b(0x0600, inq_ptr->version4); 10559 break; 10560 case T_PROCESSOR: 10561 default: 10562 break; 10563 } 10564 } 10565 | 10212 return (CTL_RETVAL_COMPLETE); 10213} 10214 10215static int 10216ctl_inquiry_evpd(struct ctl_scsiio *ctsio) 10217{ 10218 struct scsi_inquiry *cdb; 10219 int alloc_len, retval; --- 283 unchanged lines hidden (view full) --- 10503 scsi_ulto2b(0x0600, inq_ptr->version4); 10504 break; 10505 case T_PROCESSOR: 10506 default: 10507 break; 10508 } 10509 } 10510 |
10566 ctsio->scsi_status = SCSI_STATUS_OK; | 10511 ctl_set_success(ctsio); |
10567 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 10568 ctsio->be_move_done = ctl_config_move_done; 10569 ctl_datamove((union ctl_io *)ctsio); 10570 return (CTL_RETVAL_COMPLETE); 10571} 10572 10573int 10574ctl_inquiry(struct ctl_scsiio *ctsio) --- 2954 unchanged lines hidden (view full) --- 13529 } 13530 13531 mtx_lock(&lun->lun_lock); 13532 13533 /* 13534 * Check to see if we have any errors to inject here. We only 13535 * inject errors for commands that don't already have errors set. 13536 */ | 10512 ctsio->io_hdr.flags |= CTL_FLAG_ALLOCATED; 10513 ctsio->be_move_done = ctl_config_move_done; 10514 ctl_datamove((union ctl_io *)ctsio); 10515 return (CTL_RETVAL_COMPLETE); 10516} 10517 10518int 10519ctl_inquiry(struct ctl_scsiio *ctsio) --- 2954 unchanged lines hidden (view full) --- 13474 } 13475 13476 mtx_lock(&lun->lun_lock); 13477 13478 /* 13479 * Check to see if we have any errors to inject here. We only 13480 * inject errors for commands that don't already have errors set. 13481 */ |
13537 if ((STAILQ_FIRST(&lun->error_list) != NULL) 13538 && ((io->io_hdr.status & CTL_STATUS_MASK) == CTL_SUCCESS)) | 13482 if ((STAILQ_FIRST(&lun->error_list) != NULL) && 13483 ((io->io_hdr.status & CTL_STATUS_MASK) == CTL_SUCCESS) && 13484 ((io->io_hdr.flags & CTL_FLAG_STATUS_SENT) == 0)) |
13539 ctl_inject_error(lun, io); 13540 13541 /* 13542 * XXX KDM how do we treat commands that aren't completed 13543 * successfully? 13544 * 13545 * XXX KDM should we also track I/O latency? 13546 */ --- 693 unchanged lines hidden --- | 13485 ctl_inject_error(lun, io); 13486 13487 /* 13488 * XXX KDM how do we treat commands that aren't completed 13489 * successfully? 13490 * 13491 * XXX KDM should we also track I/O latency? 13492 */ --- 693 unchanged lines hidden --- |