Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the zfcp device driver for |
| 3 | * FCP adapters for IBM System z9 and zSeries. |
| 4 | * |
Christof Schmitt | d46f384 | 2009-08-18 15:43:07 +0200 | [diff] [blame] | 5 | * Copyright IBM Corp. 2008, 2009 |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2, or (at your option) |
| 10 | * any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 20 | */ |
| 21 | |
| 22 | #ifndef ZFCP_DBF_H |
| 23 | #define ZFCP_DBF_H |
| 24 | |
Christof Schmitt | dcd20e2 | 2009-08-18 15:43:08 +0200 | [diff] [blame] | 25 | #include "zfcp_ext.h" |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 26 | #include "zfcp_fsf.h" |
Christof Schmitt | dcd20e2 | 2009-08-18 15:43:08 +0200 | [diff] [blame] | 27 | #include "zfcp_def.h" |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 28 | |
| 29 | #define ZFCP_DBF_TAG_SIZE 4 |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 30 | #define ZFCP_DBF_ID_SIZE 7 |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 31 | |
| 32 | struct zfcp_dbf_dump { |
| 33 | u8 tag[ZFCP_DBF_TAG_SIZE]; |
| 34 | u32 total_size; /* size of total dump data */ |
| 35 | u32 offset; /* how much data has being already dumped */ |
| 36 | u32 size; /* how much data comes with this record */ |
| 37 | u8 data[]; /* dump data */ |
| 38 | } __attribute__ ((packed)); |
| 39 | |
| 40 | struct zfcp_rec_dbf_record_thread { |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 41 | u32 total; |
| 42 | u32 ready; |
| 43 | u32 running; |
Martin Peschke | 7337891 | 2008-05-19 12:17:46 +0200 | [diff] [blame] | 44 | }; |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 45 | |
| 46 | struct zfcp_rec_dbf_record_target { |
| 47 | u64 ref; |
| 48 | u32 status; |
| 49 | u32 d_id; |
| 50 | u64 wwpn; |
| 51 | u64 fcp_lun; |
| 52 | u32 erp_count; |
Martin Peschke | 7337891 | 2008-05-19 12:17:46 +0200 | [diff] [blame] | 53 | }; |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 54 | |
| 55 | struct zfcp_rec_dbf_record_trigger { |
| 56 | u8 want; |
| 57 | u8 need; |
| 58 | u32 as; |
| 59 | u32 ps; |
| 60 | u32 us; |
| 61 | u64 ref; |
| 62 | u64 action; |
| 63 | u64 wwpn; |
| 64 | u64 fcp_lun; |
Martin Peschke | 7337891 | 2008-05-19 12:17:46 +0200 | [diff] [blame] | 65 | }; |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 66 | |
| 67 | struct zfcp_rec_dbf_record_action { |
| 68 | u32 status; |
| 69 | u32 step; |
| 70 | u64 action; |
| 71 | u64 fsf_req; |
Martin Peschke | 7337891 | 2008-05-19 12:17:46 +0200 | [diff] [blame] | 72 | }; |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 73 | |
| 74 | struct zfcp_rec_dbf_record { |
| 75 | u8 id; |
Swen Schillig | 5ffd51a | 2009-03-02 13:09:04 +0100 | [diff] [blame] | 76 | char id2[7]; |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 77 | union { |
| 78 | struct zfcp_rec_dbf_record_action action; |
| 79 | struct zfcp_rec_dbf_record_thread thread; |
| 80 | struct zfcp_rec_dbf_record_target target; |
| 81 | struct zfcp_rec_dbf_record_trigger trigger; |
| 82 | } u; |
Martin Peschke | 7337891 | 2008-05-19 12:17:46 +0200 | [diff] [blame] | 83 | }; |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 84 | |
| 85 | enum { |
| 86 | ZFCP_REC_DBF_ID_ACTION, |
| 87 | ZFCP_REC_DBF_ID_THREAD, |
| 88 | ZFCP_REC_DBF_ID_TARGET, |
| 89 | ZFCP_REC_DBF_ID_TRIGGER, |
| 90 | }; |
| 91 | |
| 92 | struct zfcp_hba_dbf_record_response { |
| 93 | u32 fsf_command; |
| 94 | u64 fsf_reqid; |
| 95 | u32 fsf_seqno; |
| 96 | u64 fsf_issued; |
| 97 | u32 fsf_prot_status; |
| 98 | u32 fsf_status; |
| 99 | u8 fsf_prot_status_qual[FSF_PROT_STATUS_QUAL_SIZE]; |
| 100 | u8 fsf_status_qual[FSF_STATUS_QUALIFIER_SIZE]; |
| 101 | u32 fsf_req_status; |
| 102 | u8 sbal_first; |
Martin Peschke | e891bff | 2008-05-19 12:17:43 +0200 | [diff] [blame] | 103 | u8 sbal_last; |
Martin Peschke | c3baa9a2 | 2008-05-19 12:17:44 +0200 | [diff] [blame] | 104 | u8 sbal_response; |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 105 | u8 pool; |
| 106 | u64 erp_action; |
| 107 | union { |
| 108 | struct { |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 109 | u64 cmnd; |
| 110 | u64 serial; |
| 111 | } fcp; |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 112 | struct { |
| 113 | u64 wwpn; |
| 114 | u32 d_id; |
| 115 | u32 port_handle; |
| 116 | } port; |
| 117 | struct { |
| 118 | u64 wwpn; |
| 119 | u64 fcp_lun; |
| 120 | u32 port_handle; |
| 121 | u32 lun_handle; |
| 122 | } unit; |
| 123 | struct { |
| 124 | u32 d_id; |
| 125 | u8 ls_code; |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 126 | } els; |
| 127 | } u; |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 128 | } __attribute__ ((packed)); |
| 129 | |
| 130 | struct zfcp_hba_dbf_record_status { |
| 131 | u8 failed; |
| 132 | u32 status_type; |
| 133 | u32 status_subtype; |
| 134 | struct fsf_queue_designator |
| 135 | queue_designator; |
| 136 | u32 payload_size; |
| 137 | #define ZFCP_DBF_UNSOL_PAYLOAD 80 |
| 138 | #define ZFCP_DBF_UNSOL_PAYLOAD_SENSE_DATA_AVAIL 32 |
| 139 | #define ZFCP_DBF_UNSOL_PAYLOAD_BIT_ERROR_THRESHOLD 56 |
| 140 | #define ZFCP_DBF_UNSOL_PAYLOAD_FEATURE_UPDATE_ALERT 2 * sizeof(u32) |
| 141 | u8 payload[ZFCP_DBF_UNSOL_PAYLOAD]; |
| 142 | } __attribute__ ((packed)); |
| 143 | |
| 144 | struct zfcp_hba_dbf_record_qdio { |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 145 | u32 qdio_error; |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 146 | u8 sbal_index; |
| 147 | u8 sbal_count; |
| 148 | } __attribute__ ((packed)); |
| 149 | |
| 150 | struct zfcp_hba_dbf_record { |
| 151 | u8 tag[ZFCP_DBF_TAG_SIZE]; |
| 152 | u8 tag2[ZFCP_DBF_TAG_SIZE]; |
| 153 | union { |
| 154 | struct zfcp_hba_dbf_record_response response; |
| 155 | struct zfcp_hba_dbf_record_status status; |
| 156 | struct zfcp_hba_dbf_record_qdio qdio; |
Swen Schillig | 5706938 | 2008-10-01 12:42:21 +0200 | [diff] [blame] | 157 | struct fsf_bit_error_payload berr; |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 158 | } u; |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 159 | } __attribute__ ((packed)); |
| 160 | |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 161 | struct zfcp_san_dbf_record_ct_request { |
| 162 | u16 cmd_req_code; |
| 163 | u8 revision; |
| 164 | u8 gs_type; |
| 165 | u8 gs_subtype; |
| 166 | u8 options; |
| 167 | u16 max_res_size; |
| 168 | u32 len; |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 169 | } __attribute__ ((packed)); |
| 170 | |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 171 | struct zfcp_san_dbf_record_ct_response { |
| 172 | u16 cmd_rsp_code; |
| 173 | u8 revision; |
| 174 | u8 reason_code; |
| 175 | u8 expl; |
| 176 | u8 vendor_unique; |
Christof Schmitt | 39eb7e9a | 2008-12-19 16:57:01 +0100 | [diff] [blame] | 177 | u16 max_res_size; |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 178 | u32 len; |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 179 | } __attribute__ ((packed)); |
| 180 | |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 181 | struct zfcp_san_dbf_record_els { |
| 182 | u8 ls_code; |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 183 | u32 len; |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 184 | } __attribute__ ((packed)); |
| 185 | |
| 186 | struct zfcp_san_dbf_record { |
| 187 | u8 tag[ZFCP_DBF_TAG_SIZE]; |
| 188 | u64 fsf_reqid; |
| 189 | u32 fsf_seqno; |
| 190 | u32 s_id; |
| 191 | u32 d_id; |
| 192 | union { |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 193 | struct zfcp_san_dbf_record_ct_request ct_req; |
| 194 | struct zfcp_san_dbf_record_ct_response ct_resp; |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 195 | struct zfcp_san_dbf_record_els els; |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 196 | } u; |
Christof Schmitt | d94ce6c | 2008-11-04 16:35:12 +0100 | [diff] [blame] | 197 | #define ZFCP_DBF_SAN_MAX_PAYLOAD 1024 |
| 198 | u8 payload[32]; |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 199 | } __attribute__ ((packed)); |
| 200 | |
| 201 | struct zfcp_scsi_dbf_record { |
| 202 | u8 tag[ZFCP_DBF_TAG_SIZE]; |
| 203 | u8 tag2[ZFCP_DBF_TAG_SIZE]; |
| 204 | u32 scsi_id; |
| 205 | u32 scsi_lun; |
| 206 | u32 scsi_result; |
| 207 | u64 scsi_cmnd; |
| 208 | u64 scsi_serial; |
| 209 | #define ZFCP_DBF_SCSI_OPCODE 16 |
| 210 | u8 scsi_opcode[ZFCP_DBF_SCSI_OPCODE]; |
| 211 | u8 scsi_retries; |
| 212 | u8 scsi_allowed; |
| 213 | u64 fsf_reqid; |
| 214 | u32 fsf_seqno; |
| 215 | u64 fsf_issued; |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 216 | u64 old_fsf_reqid; |
| 217 | u8 rsp_validity; |
| 218 | u8 rsp_scsi_status; |
| 219 | u32 rsp_resid; |
| 220 | u8 rsp_code; |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 221 | #define ZFCP_DBF_SCSI_FCP_SNS_INFO 16 |
| 222 | #define ZFCP_DBF_SCSI_MAX_FCP_SNS_INFO 256 |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 223 | u32 sns_info_len; |
| 224 | u8 sns_info[ZFCP_DBF_SCSI_FCP_SNS_INFO]; |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 225 | } __attribute__ ((packed)); |
| 226 | |
Christof Schmitt | d46f384 | 2009-08-18 15:43:07 +0200 | [diff] [blame] | 227 | struct zfcp_dbf { |
| 228 | debug_info_t *rec_dbf; |
| 229 | debug_info_t *hba_dbf; |
| 230 | debug_info_t *san_dbf; |
| 231 | debug_info_t *scsi_dbf; |
| 232 | spinlock_t rec_dbf_lock; |
| 233 | spinlock_t hba_dbf_lock; |
| 234 | spinlock_t san_dbf_lock; |
| 235 | spinlock_t scsi_dbf_lock; |
| 236 | struct zfcp_rec_dbf_record rec_dbf_buf; |
| 237 | struct zfcp_hba_dbf_record hba_dbf_buf; |
| 238 | struct zfcp_san_dbf_record san_dbf_buf; |
| 239 | struct zfcp_scsi_dbf_record scsi_dbf_buf; |
| 240 | }; |
| 241 | |
Christof Schmitt | dcd20e2 | 2009-08-18 15:43:08 +0200 | [diff] [blame] | 242 | static inline |
Christof Schmitt | 2e261af | 2009-08-18 15:43:09 +0200 | [diff] [blame^] | 243 | void zfcp_hba_dbf_event_fsf_resp(const char *tag2, int level, |
| 244 | struct zfcp_fsf_req *req, struct zfcp_dbf *dbf) |
| 245 | { |
| 246 | if (level <= dbf->hba_dbf->level) |
| 247 | _zfcp_hba_dbf_event_fsf_response(tag2, level, req, dbf); |
| 248 | } |
| 249 | |
| 250 | /** |
| 251 | * zfcp_hba_dbf_event_fsf_response - trace event for request completion |
| 252 | * @fsf_req: request that has been completed |
| 253 | */ |
| 254 | static inline void zfcp_hba_dbf_event_fsf_response(struct zfcp_fsf_req *req) |
| 255 | { |
| 256 | struct zfcp_dbf *dbf = req->adapter->dbf; |
| 257 | struct fsf_qtcb *qtcb = req->qtcb; |
| 258 | |
| 259 | if ((qtcb->prefix.prot_status != FSF_PROT_GOOD) && |
| 260 | (qtcb->prefix.prot_status != FSF_PROT_FSF_STATUS_PRESENTED)) { |
| 261 | zfcp_hba_dbf_event_fsf_resp("perr", 1, req, dbf); |
| 262 | |
| 263 | } else if (qtcb->header.fsf_status != FSF_GOOD) { |
| 264 | zfcp_hba_dbf_event_fsf_resp("ferr", 1, req, dbf); |
| 265 | |
| 266 | } else if ((req->fsf_command == FSF_QTCB_OPEN_PORT_WITH_DID) || |
| 267 | (req->fsf_command == FSF_QTCB_OPEN_LUN)) { |
| 268 | zfcp_hba_dbf_event_fsf_resp("open", 4, req, dbf); |
| 269 | |
| 270 | } else if (qtcb->header.log_length) { |
| 271 | zfcp_hba_dbf_event_fsf_resp("qtcb", 5, req, dbf); |
| 272 | |
| 273 | } else { |
| 274 | zfcp_hba_dbf_event_fsf_resp("norm", 6, req, dbf); |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | /** |
| 279 | * zfcp_hba_dbf_event_fsf_unsol - trace event for an unsolicited status buffer |
| 280 | * @tag: tag indicating which kind of unsolicited status has been received |
| 281 | * @adapter: adapter that has issued the unsolicited status buffer |
| 282 | * @status_buffer: buffer containing payload of unsolicited status |
| 283 | */ |
| 284 | static inline |
| 285 | void zfcp_hba_dbf_event_fsf_unsol(const char *tag, struct zfcp_adapter *adapter, |
| 286 | struct fsf_status_read_buffer *buf) |
| 287 | { |
| 288 | struct zfcp_dbf *dbf = adapter->dbf; |
| 289 | int level = 2; |
| 290 | |
| 291 | if (level <= dbf->hba_dbf->level) |
| 292 | _zfcp_hba_dbf_event_fsf_unsol(tag, level, adapter, buf); |
| 293 | } |
| 294 | |
| 295 | static inline |
Christof Schmitt | dcd20e2 | 2009-08-18 15:43:08 +0200 | [diff] [blame] | 296 | void zfcp_scsi_dbf_event(const char *tag, const char *tag2, int level, |
| 297 | struct zfcp_adapter *adapter, struct scsi_cmnd *scmd, |
| 298 | struct zfcp_fsf_req *req, unsigned long old_id) |
| 299 | { |
| 300 | struct zfcp_dbf *dbf = adapter->dbf; |
| 301 | |
| 302 | if (level <= dbf->scsi_dbf->level) |
| 303 | _zfcp_scsi_dbf_event(tag, tag2, level, dbf, scmd, req, old_id); |
| 304 | } |
| 305 | |
| 306 | /** |
| 307 | * zfcp_scsi_dbf_event_result - trace event for SCSI command completion |
| 308 | * @tag: tag indicating success or failure of SCSI command |
| 309 | * @level: trace level applicable for this event |
| 310 | * @adapter: adapter that has been used to issue the SCSI command |
| 311 | * @scmd: SCSI command pointer |
| 312 | * @fsf_req: request used to issue SCSI command (might be NULL) |
| 313 | */ |
| 314 | static inline |
| 315 | void zfcp_scsi_dbf_event_result(const char *tag, int level, |
| 316 | struct zfcp_adapter *adapter, |
| 317 | struct scsi_cmnd *scmd, |
| 318 | struct zfcp_fsf_req *fsf_req) |
| 319 | { |
| 320 | zfcp_scsi_dbf_event("rslt", tag, level, adapter, scmd, fsf_req, 0); |
| 321 | } |
| 322 | |
| 323 | /** |
| 324 | * zfcp_scsi_dbf_event_abort - trace event for SCSI command abort |
| 325 | * @tag: tag indicating success or failure of abort operation |
| 326 | * @adapter: adapter thas has been used to issue SCSI command to be aborted |
| 327 | * @scmd: SCSI command to be aborted |
| 328 | * @new_req: request containing abort (might be NULL) |
| 329 | * @old_id: identifier of request containg SCSI command to be aborted |
| 330 | */ |
| 331 | static inline |
| 332 | void zfcp_scsi_dbf_event_abort(const char *tag, struct zfcp_adapter *adapter, |
| 333 | struct scsi_cmnd *scmd, |
| 334 | struct zfcp_fsf_req *new_req, |
| 335 | unsigned long old_id) |
| 336 | { |
| 337 | zfcp_scsi_dbf_event("abrt", tag, 1, adapter, scmd, new_req, old_id); |
| 338 | } |
| 339 | |
| 340 | /** |
| 341 | * zfcp_scsi_dbf_event_devreset - trace event for Logical Unit or Target Reset |
| 342 | * @tag: tag indicating success or failure of reset operation |
| 343 | * @flag: indicates type of reset (Target Reset, Logical Unit Reset) |
| 344 | * @unit: unit that needs reset |
| 345 | * @scsi_cmnd: SCSI command which caused this error recovery |
| 346 | */ |
| 347 | static inline |
| 348 | void zfcp_scsi_dbf_event_devreset(const char *tag, u8 flag, |
| 349 | struct zfcp_unit *unit, |
| 350 | struct scsi_cmnd *scsi_cmnd) |
| 351 | { |
| 352 | zfcp_scsi_dbf_event(flag == FCP_TARGET_RESET ? "trst" : "lrst", tag, 1, |
| 353 | unit->port->adapter, scsi_cmnd, NULL, 0); |
| 354 | } |
| 355 | |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 356 | #endif /* ZFCP_DBF_H */ |