cam_periph.c (224496) | cam_periph.c (225950) |
---|---|
1/*- 2 * Common functions for CAM "type" (peripheral) drivers. 3 * 4 * Copyright (c) 1997, 1998 Justin T. Gibbs. 5 * Copyright (c) 1997, 1998, 1999, 2000 Kenneth D. Merry. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> | 1/*- 2 * Common functions for CAM "type" (peripheral) drivers. 3 * 4 * Copyright (c) 1997, 1998 Justin T. Gibbs. 5 * Copyright (c) 1997, 1998, 1999, 2000 Kenneth D. Merry. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> |
31__FBSDID("$FreeBSD: head/sys/cam/cam_periph.c 224496 2011-07-29 20:30:28Z mav $"); | 31__FBSDID("$FreeBSD: head/sys/cam/cam_periph.c 225950 2011-10-03 20:32:55Z ken $"); |
32 33#include <sys/param.h> 34#include <sys/systm.h> 35#include <sys/types.h> 36#include <sys/malloc.h> 37#include <sys/kernel.h> 38#include <sys/bio.h> 39#include <sys/lock.h> --- 1040 unchanged lines hidden (view full) --- 1080#define saved_ccb_ptr ppriv_ptr0 1081#define recovery_depth ppriv_field1 1082static void 1083camperiphsensedone(struct cam_periph *periph, union ccb *done_ccb) 1084{ 1085 union ccb *saved_ccb = (union ccb *)done_ccb->ccb_h.saved_ccb_ptr; 1086 cam_status status; 1087 int frozen = 0; | 32 33#include <sys/param.h> 34#include <sys/systm.h> 35#include <sys/types.h> 36#include <sys/malloc.h> 37#include <sys/kernel.h> 38#include <sys/bio.h> 39#include <sys/lock.h> --- 1040 unchanged lines hidden (view full) --- 1080#define saved_ccb_ptr ppriv_ptr0 1081#define recovery_depth ppriv_field1 1082static void 1083camperiphsensedone(struct cam_periph *periph, union ccb *done_ccb) 1084{ 1085 union ccb *saved_ccb = (union ccb *)done_ccb->ccb_h.saved_ccb_ptr; 1086 cam_status status; 1087 int frozen = 0; |
1088 u_int sense_key; | |
1089 int depth = done_ccb->ccb_h.recovery_depth; 1090 1091 status = done_ccb->ccb_h.status; 1092 if (status & CAM_DEV_QFRZN) { 1093 frozen = 1; 1094 /* 1095 * Clear freeze flag now for case of retry, 1096 * freeze will be dropped later. 1097 */ 1098 done_ccb->ccb_h.status &= ~CAM_DEV_QFRZN; 1099 } 1100 status &= CAM_STATUS_MASK; 1101 switch (status) { 1102 case CAM_REQ_CMP: 1103 { | 1088 int depth = done_ccb->ccb_h.recovery_depth; 1089 1090 status = done_ccb->ccb_h.status; 1091 if (status & CAM_DEV_QFRZN) { 1092 frozen = 1; 1093 /* 1094 * Clear freeze flag now for case of retry, 1095 * freeze will be dropped later. 1096 */ 1097 done_ccb->ccb_h.status &= ~CAM_DEV_QFRZN; 1098 } 1099 status &= CAM_STATUS_MASK; 1100 switch (status) { 1101 case CAM_REQ_CMP: 1102 { |
1103 int error_code, sense_key, asc, ascq; 1104 1105 scsi_extract_sense_len(&saved_ccb->csio.sense_data, 1106 saved_ccb->csio.sense_len - 1107 saved_ccb->csio.sense_resid, 1108 &error_code, &sense_key, &asc, &ascq, 1109 /*show_errors*/ 1); |
|
1104 /* 1105 * If we manually retrieved sense into a CCB and got 1106 * something other than "NO SENSE" send the updated CCB 1107 * back to the client via xpt_done() to be processed via 1108 * the error recovery code again. 1109 */ | 1110 /* 1111 * If we manually retrieved sense into a CCB and got 1112 * something other than "NO SENSE" send the updated CCB 1113 * back to the client via xpt_done() to be processed via 1114 * the error recovery code again. 1115 */ |
1110 sense_key = saved_ccb->csio.sense_data.flags; 1111 sense_key &= SSD_KEY; 1112 if (sense_key != SSD_KEY_NO_SENSE) { 1113 saved_ccb->ccb_h.status |= 1114 CAM_AUTOSNS_VALID; | 1116 if ((sense_key != -1) 1117 && (sense_key != SSD_KEY_NO_SENSE)) { 1118 saved_ccb->ccb_h.status |= CAM_AUTOSNS_VALID; |
1115 } else { | 1119 } else { |
1116 saved_ccb->ccb_h.status &= 1117 ~CAM_STATUS_MASK; 1118 saved_ccb->ccb_h.status |= 1119 CAM_AUTOSENSE_FAIL; | 1120 saved_ccb->ccb_h.status &= ~CAM_STATUS_MASK; 1121 saved_ccb->ccb_h.status |= CAM_AUTOSENSE_FAIL; |
1120 } 1121 saved_ccb->csio.sense_resid = done_ccb->csio.resid; 1122 bcopy(saved_ccb, done_ccb, sizeof(union ccb)); 1123 xpt_free_ccb(saved_ccb); 1124 break; 1125 } 1126 default: 1127 bcopy(saved_ccb, done_ccb, sizeof(union ccb)); --- 65 unchanged lines hidden (view full) --- 1193 goto final; 1194 } 1195 case CAM_SCSI_STATUS_ERROR: 1196 scsi_cmd = (struct scsi_start_stop_unit *) 1197 &done_ccb->csio.cdb_io.cdb_bytes; 1198 if (status & CAM_AUTOSNS_VALID) { 1199 struct ccb_getdev cgd; 1200 struct scsi_sense_data *sense; | 1122 } 1123 saved_ccb->csio.sense_resid = done_ccb->csio.resid; 1124 bcopy(saved_ccb, done_ccb, sizeof(union ccb)); 1125 xpt_free_ccb(saved_ccb); 1126 break; 1127 } 1128 default: 1129 bcopy(saved_ccb, done_ccb, sizeof(union ccb)); --- 65 unchanged lines hidden (view full) --- 1195 goto final; 1196 } 1197 case CAM_SCSI_STATUS_ERROR: 1198 scsi_cmd = (struct scsi_start_stop_unit *) 1199 &done_ccb->csio.cdb_io.cdb_bytes; 1200 if (status & CAM_AUTOSNS_VALID) { 1201 struct ccb_getdev cgd; 1202 struct scsi_sense_data *sense; |
1201 int error_code, sense_key, asc, ascq; | 1203 int error_code, sense_key, asc, ascq, sense_len; |
1202 scsi_sense_action err_action; 1203 1204 sense = &done_ccb->csio.sense_data; | 1204 scsi_sense_action err_action; 1205 1206 sense = &done_ccb->csio.sense_data; |
1205 scsi_extract_sense(sense, &error_code, 1206 &sense_key, &asc, &ascq); | 1207 sense_len = done_ccb->csio.sense_len - 1208 done_ccb->csio.sense_resid; 1209 scsi_extract_sense_len(sense, sense_len, &error_code, 1210 &sense_key, &asc, &ascq, 1211 /*show_errors*/ 1); |
1207 /* 1208 * Grab the inquiry data for this device. 1209 */ 1210 xpt_setup_ccb(&cgd.ccb_h, done_ccb->ccb_h.path, 1211 CAM_PRIORITY_NORMAL); 1212 cgd.ccb_h.func_code = XPT_GDEV_TYPE; 1213 xpt_action((union ccb *)&cgd); 1214 err_action = scsi_error_action(&done_ccb->csio, --- 740 unchanged lines hidden --- | 1212 /* 1213 * Grab the inquiry data for this device. 1214 */ 1215 xpt_setup_ccb(&cgd.ccb_h, done_ccb->ccb_h.path, 1216 CAM_PRIORITY_NORMAL); 1217 cgd.ccb_h.func_code = XPT_GDEV_TYPE; 1218 xpt_action((union ccb *)&cgd); 1219 err_action = scsi_error_action(&done_ccb->csio, --- 740 unchanged lines hidden --- |