scsi_target.c (76192) | scsi_target.c (76362) |
---|---|
1/* 2 * Implementation of a simple Target Mode SCSI Proccessor Target driver for CAM. 3 * 4 * Copyright (c) 1998, 1999 Justin T. Gibbs. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 11 unchanged lines hidden (view full) --- 20 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * | 1/* 2 * Implementation of a simple Target Mode SCSI Proccessor Target driver for CAM. 3 * 4 * Copyright (c) 1998, 1999 Justin T. Gibbs. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 11 unchanged lines hidden (view full) --- 20 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * |
28 * $FreeBSD: head/sys/cam/scsi/scsi_target.c 76192 2001-05-01 19:37:25Z ken $ | 28 * $FreeBSD: head/sys/cam/scsi/scsi_target.c 76362 2001-05-08 08:30:48Z phk $ |
29 */ 30 31#include <sys/param.h> 32#include <sys/queue.h> 33#include <sys/systm.h> 34#include <sys/kernel.h> 35#include <sys/types.h> 36#include <sys/bio.h> --- 1113 unchanged lines hidden (view full) --- 1150targstrategy(struct bio *bp) 1151{ 1152 struct cam_periph *periph; 1153 struct targ_softc *softc; 1154 u_int unit; 1155 int s; 1156 1157 unit = minor(bp->bio_dev); | 29 */ 30 31#include <sys/param.h> 32#include <sys/queue.h> 33#include <sys/systm.h> 34#include <sys/kernel.h> 35#include <sys/types.h> 36#include <sys/bio.h> --- 1113 unchanged lines hidden (view full) --- 1150targstrategy(struct bio *bp) 1151{ 1152 struct cam_periph *periph; 1153 struct targ_softc *softc; 1154 u_int unit; 1155 int s; 1156 1157 unit = minor(bp->bio_dev); |
1158 bp->bio_resid = bp->bio_bcount; |
|
1158 1159 /* ioctl is the only supported operation of the control device */ 1160 if (TARG_IS_CONTROL_DEV(unit)) { | 1159 1160 /* ioctl is the only supported operation of the control device */ 1161 if (TARG_IS_CONTROL_DEV(unit)) { |
1161 bp->bio_error = EINVAL; 1162 goto bad; | 1162 biofinish(bp, NULL, EINVAL); 1163 return; |
1163 } 1164 1165 periph = cam_extend_get(targperiphs, unit); 1166 if (periph == NULL) { | 1164 } 1165 1166 periph = cam_extend_get(targperiphs, unit); 1167 if (periph == NULL) { |
1167 bp->bio_error = ENXIO; 1168 goto bad; | 1168 biofinish(bp, NULL, ENXIO); 1169 return; |
1169 } 1170 softc = (struct targ_softc *)periph->softc; 1171 1172 /* 1173 * Mask interrupts so that the device cannot be invalidated until 1174 * after we are in the queue. Otherwise, we might not properly 1175 * clean up one of the buffers. 1176 */ 1177 s = splbio(); 1178 1179 /* 1180 * If there is an exception pending, error out 1181 */ 1182 if (softc->state != TARG_STATE_NORMAL) { 1183 splx(s); 1184 if (softc->state == TARG_STATE_EXCEPTION 1185 && (softc->exceptions & TARG_EXCEPT_DEVICE_INVALID) == 0) | 1170 } 1171 softc = (struct targ_softc *)periph->softc; 1172 1173 /* 1174 * Mask interrupts so that the device cannot be invalidated until 1175 * after we are in the queue. Otherwise, we might not properly 1176 * clean up one of the buffers. 1177 */ 1178 s = splbio(); 1179 1180 /* 1181 * If there is an exception pending, error out 1182 */ 1183 if (softc->state != TARG_STATE_NORMAL) { 1184 splx(s); 1185 if (softc->state == TARG_STATE_EXCEPTION 1186 && (softc->exceptions & TARG_EXCEPT_DEVICE_INVALID) == 0) |
1186 bp->bio_error = EBUSY; | 1187 s = EBUSY; |
1187 else | 1188 else |
1188 bp->bio_error = ENXIO; 1189 goto bad; | 1189 s = ENXIO; 1190 biofinish(bp, NULL, s); 1191 return; |
1190 } 1191 1192 /* 1193 * Place it in the queue of buffers available for either 1194 * SEND or RECEIVE commands. 1195 * 1196 */ 1197 bp->bio_resid = bp->bio_bcount; --- 11 unchanged lines hidden (view full) --- 1209 1210 /* 1211 * Attempt to use the new buffer to service any pending 1212 * target commands. 1213 */ 1214 targrunqueue(periph, softc); 1215 1216 return; | 1192 } 1193 1194 /* 1195 * Place it in the queue of buffers available for either 1196 * SEND or RECEIVE commands. 1197 * 1198 */ 1199 bp->bio_resid = bp->bio_bcount; --- 11 unchanged lines hidden (view full) --- 1211 1212 /* 1213 * Attempt to use the new buffer to service any pending 1214 * target commands. 1215 */ 1216 targrunqueue(periph, softc); 1217 1218 return; |
1217bad: 1218 bp->bio_flags |= BIO_ERROR; 1219 1220 /* 1221 * Correctly set the buf to indicate a completed xfer 1222 */ 1223 bp->bio_resid = bp->bio_bcount; 1224 biodone(bp); | |
1225} 1226 1227static void 1228targrunqueue(struct cam_periph *periph, struct targ_softc *softc) 1229{ 1230 struct ccb_queue *pending_queue; 1231 struct ccb_accept_tio *atio; 1232 struct bio_queue_head *bioq; --- 1061 unchanged lines hidden --- | 1219} 1220 1221static void 1222targrunqueue(struct cam_periph *periph, struct targ_softc *softc) 1223{ 1224 struct ccb_queue *pending_queue; 1225 struct ccb_accept_tio *atio; 1226 struct bio_queue_head *bioq; --- 1061 unchanged lines hidden --- |