diff options
author | Andrew Vasquez <andrew.vasquez@qlogic.com> | 2008-01-17 12:02:07 -0500 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2008-01-23 12:29:29 -0500 |
commit | 4733fcb1fe4d64402a8bd18cec766e8b8ad25eee (patch) | |
tree | 145519223ad9067a64025807481f37492ea1adb6 /drivers/scsi/qla2xxx | |
parent | fd66c1b4e491a2a17d7a420fa38fd04b0e8d36c1 (diff) |
[SCSI] qla2xxx: Consolidate duplicate sense-data handling codes.
Signed-off-by: Andrew Vasquez <andrew.vasquez@qlogic.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/scsi/qla2xxx')
-rw-r--r-- | drivers/scsi/qla2xxx/qla_isr.c | 85 |
1 files changed, 31 insertions, 54 deletions
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c index 53cbaffbb78c..5d2dc92f7d9d 100644 --- a/drivers/scsi/qla2xxx/qla_isr.c +++ b/drivers/scsi/qla2xxx/qla_isr.c | |||
@@ -822,6 +822,35 @@ qla2x00_process_response_queue(struct scsi_qla_host *ha) | |||
822 | WRT_REG_WORD(ISP_RSP_Q_OUT(ha, reg), ha->rsp_ring_index); | 822 | WRT_REG_WORD(ISP_RSP_Q_OUT(ha, reg), ha->rsp_ring_index); |
823 | } | 823 | } |
824 | 824 | ||
825 | static inline void | ||
826 | qla2x00_handle_sense(srb_t *sp, uint8_t *sense_data, uint32_t sense_len) | ||
827 | { | ||
828 | struct scsi_cmnd *cp = sp->cmd; | ||
829 | |||
830 | if (sense_len >= SCSI_SENSE_BUFFERSIZE) | ||
831 | sense_len = SCSI_SENSE_BUFFERSIZE; | ||
832 | |||
833 | CMD_ACTUAL_SNSLEN(cp) = sense_len; | ||
834 | sp->request_sense_length = sense_len; | ||
835 | sp->request_sense_ptr = cp->sense_buffer; | ||
836 | if (sp->request_sense_length > 32) | ||
837 | sense_len = 32; | ||
838 | |||
839 | memcpy(cp->sense_buffer, sense_data, sense_len); | ||
840 | |||
841 | sp->request_sense_ptr += sense_len; | ||
842 | sp->request_sense_length -= sense_len; | ||
843 | if (sp->request_sense_length != 0) | ||
844 | sp->ha->status_srb = sp; | ||
845 | |||
846 | DEBUG5(printk("%s(): Check condition Sense data, scsi(%ld:%d:%d:%d) " | ||
847 | "cmd=%p pid=%ld\n", __func__, sp->ha->host_no, cp->device->channel, | ||
848 | cp->device->id, cp->device->lun, cp, cp->serial_number)); | ||
849 | if (sense_len) | ||
850 | DEBUG5(qla2x00_dump_buffer(cp->sense_buffer, | ||
851 | CMD_ACTUAL_SNSLEN(cp))); | ||
852 | } | ||
853 | |||
825 | /** | 854 | /** |
826 | * qla2x00_status_entry() - Process a Status IOCB entry. | 855 | * qla2x00_status_entry() - Process a Status IOCB entry. |
827 | * @ha: SCSI driver HA context | 856 | * @ha: SCSI driver HA context |
@@ -976,36 +1005,11 @@ qla2x00_status_entry(scsi_qla_host_t *ha, void *pkt) | |||
976 | if (lscsi_status != SS_CHECK_CONDITION) | 1005 | if (lscsi_status != SS_CHECK_CONDITION) |
977 | break; | 1006 | break; |
978 | 1007 | ||
979 | /* Copy Sense Data into sense buffer. */ | ||
980 | memset(cp->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); | 1008 | memset(cp->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); |
981 | |||
982 | if (!(scsi_status & SS_SENSE_LEN_VALID)) | 1009 | if (!(scsi_status & SS_SENSE_LEN_VALID)) |
983 | break; | 1010 | break; |
984 | 1011 | ||
985 | if (sense_len >= SCSI_SENSE_BUFFERSIZE) | 1012 | qla2x00_handle_sense(sp, sense_data, sense_len); |
986 | sense_len = SCSI_SENSE_BUFFERSIZE; | ||
987 | |||
988 | CMD_ACTUAL_SNSLEN(cp) = sense_len; | ||
989 | sp->request_sense_length = sense_len; | ||
990 | sp->request_sense_ptr = cp->sense_buffer; | ||
991 | |||
992 | if (sp->request_sense_length > 32) | ||
993 | sense_len = 32; | ||
994 | |||
995 | memcpy(cp->sense_buffer, sense_data, sense_len); | ||
996 | |||
997 | sp->request_sense_ptr += sense_len; | ||
998 | sp->request_sense_length -= sense_len; | ||
999 | if (sp->request_sense_length != 0) | ||
1000 | ha->status_srb = sp; | ||
1001 | |||
1002 | DEBUG5(printk("%s(): Check condition Sense data, " | ||
1003 | "scsi(%ld:%d:%d:%d) cmd=%p pid=%ld\n", __func__, | ||
1004 | ha->host_no, cp->device->channel, cp->device->id, | ||
1005 | cp->device->lun, cp, cp->serial_number)); | ||
1006 | if (sense_len) | ||
1007 | DEBUG5(qla2x00_dump_buffer(cp->sense_buffer, | ||
1008 | CMD_ACTUAL_SNSLEN(cp))); | ||
1009 | break; | 1013 | break; |
1010 | 1014 | ||
1011 | case CS_DATA_UNDERRUN: | 1015 | case CS_DATA_UNDERRUN: |
@@ -1060,34 +1064,11 @@ qla2x00_status_entry(scsi_qla_host_t *ha, void *pkt) | |||
1060 | if (lscsi_status != SS_CHECK_CONDITION) | 1064 | if (lscsi_status != SS_CHECK_CONDITION) |
1061 | break; | 1065 | break; |
1062 | 1066 | ||
1063 | /* Copy Sense Data into sense buffer */ | ||
1064 | memset(cp->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); | 1067 | memset(cp->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); |
1065 | |||
1066 | if (!(scsi_status & SS_SENSE_LEN_VALID)) | 1068 | if (!(scsi_status & SS_SENSE_LEN_VALID)) |
1067 | break; | 1069 | break; |
1068 | 1070 | ||
1069 | if (sense_len >= SCSI_SENSE_BUFFERSIZE) | 1071 | qla2x00_handle_sense(sp, sense_data, sense_len); |
1070 | sense_len = SCSI_SENSE_BUFFERSIZE; | ||
1071 | |||
1072 | CMD_ACTUAL_SNSLEN(cp) = sense_len; | ||
1073 | sp->request_sense_length = sense_len; | ||
1074 | sp->request_sense_ptr = cp->sense_buffer; | ||
1075 | |||
1076 | if (sp->request_sense_length > 32) | ||
1077 | sense_len = 32; | ||
1078 | |||
1079 | memcpy(cp->sense_buffer, sense_data, sense_len); | ||
1080 | |||
1081 | sp->request_sense_ptr += sense_len; | ||
1082 | sp->request_sense_length -= sense_len; | ||
1083 | if (sp->request_sense_length != 0) | ||
1084 | ha->status_srb = sp; | ||
1085 | |||
1086 | DEBUG5(printk("%s(): Check condition Sense data, " | ||
1087 | "scsi(%ld:%d:%d:%d) cmd=%p pid=%ld\n", | ||
1088 | __func__, ha->host_no, cp->device->channel, | ||
1089 | cp->device->id, cp->device->lun, cp, | ||
1090 | cp->serial_number)); | ||
1091 | 1072 | ||
1092 | /* | 1073 | /* |
1093 | * In case of a Underrun condition, set both the lscsi | 1074 | * In case of a Underrun condition, set both the lscsi |
@@ -1107,10 +1088,6 @@ qla2x00_status_entry(scsi_qla_host_t *ha, void *pkt) | |||
1107 | 1088 | ||
1108 | cp->result = DID_ERROR << 16 | lscsi_status; | 1089 | cp->result = DID_ERROR << 16 | lscsi_status; |
1109 | } | 1090 | } |
1110 | |||
1111 | if (sense_len) | ||
1112 | DEBUG5(qla2x00_dump_buffer(cp->sense_buffer, | ||
1113 | CMD_ACTUAL_SNSLEN(cp))); | ||
1114 | } else { | 1091 | } else { |
1115 | /* | 1092 | /* |
1116 | * If RISC reports underrun and target does not report | 1093 | * If RISC reports underrun and target does not report |