Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 2 | /* |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 3 | * zfcp device driver |
| 4 | * debug feature declarations |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 5 | * |
Steffen Maier | 9fe5d2b | 2017-07-28 12:30:54 +0200 | [diff] [blame] | 6 | * Copyright IBM Corp. 2008, 2017 |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #ifndef ZFCP_DBF_H |
| 10 | #define ZFCP_DBF_H |
| 11 | |
Christof Schmitt | 4318e08 | 2009-11-24 16:54:08 +0100 | [diff] [blame] | 12 | #include <scsi/fc/fc_fcp.h> |
Christof Schmitt | dcd20e2 | 2009-08-18 15:43:08 +0200 | [diff] [blame] | 13 | #include "zfcp_ext.h" |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 14 | #include "zfcp_fsf.h" |
Christof Schmitt | dcd20e2 | 2009-08-18 15:43:08 +0200 | [diff] [blame] | 15 | #include "zfcp_def.h" |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 16 | |
Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 17 | #define ZFCP_DBF_TAG_LEN 7 |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 18 | |
Christof Schmitt | d21e9da | 2010-02-17 11:18:54 +0100 | [diff] [blame] | 19 | #define ZFCP_DBF_INVALID_LUN 0xFFFFFFFFFFFFFFFFull |
| 20 | |
Steffen Maier | 4eeaa4f | 2016-08-10 18:30:46 +0200 | [diff] [blame] | 21 | enum zfcp_dbf_pseudo_erp_act_type { |
| 22 | ZFCP_PSEUDO_ERP_ACTION_RPORT_ADD = 0xff, |
| 23 | ZFCP_PSEUDO_ERP_ACTION_RPORT_DEL = 0xfe, |
| 24 | }; |
| 25 | |
Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 26 | /** |
| 27 | * struct zfcp_dbf_rec_trigger - trace record for triggered recovery action |
| 28 | * @ready: number of ready recovery actions |
| 29 | * @running: number of running recovery actions |
| 30 | * @want: wanted recovery action |
| 31 | * @need: needed recovery action |
| 32 | */ |
| 33 | struct zfcp_dbf_rec_trigger { |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 34 | u32 ready; |
| 35 | u32 running; |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 36 | u8 want; |
| 37 | u8 need; |
Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 38 | } __packed; |
| 39 | |
| 40 | /** |
| 41 | * struct zfcp_dbf_rec_running - trace record for running recovery |
| 42 | * @fsf_req_id: request id for fsf requests |
| 43 | * @rec_status: status of the fsf request |
| 44 | * @rec_step: current step of the recovery action |
| 45 | * rec_count: recovery counter |
| 46 | */ |
| 47 | struct zfcp_dbf_rec_running { |
| 48 | u64 fsf_req_id; |
| 49 | u32 rec_status; |
| 50 | u16 rec_step; |
| 51 | u8 rec_action; |
| 52 | u8 rec_count; |
| 53 | } __packed; |
| 54 | |
| 55 | /** |
| 56 | * enum zfcp_dbf_rec_id - recovery trace record id |
| 57 | * @ZFCP_DBF_REC_TRIG: triggered recovery identifier |
| 58 | * @ZFCP_DBF_REC_RUN: running recovery identifier |
| 59 | */ |
| 60 | enum zfcp_dbf_rec_id { |
| 61 | ZFCP_DBF_REC_TRIG = 1, |
| 62 | ZFCP_DBF_REC_RUN = 2, |
Martin Peschke | 7337891 | 2008-05-19 12:17:46 +0200 | [diff] [blame] | 63 | }; |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 64 | |
Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 65 | /** |
| 66 | * struct zfcp_dbf_rec - trace record for error recovery actions |
| 67 | * @id: unique number of recovery record type |
| 68 | * @tag: identifier string specifying the location of initiation |
| 69 | * @lun: logical unit number |
| 70 | * @wwpn: word wide port number |
| 71 | * @d_id: destination ID |
| 72 | * @adapter_status: current status of the adapter |
| 73 | * @port_status: current status of the port |
| 74 | * @lun_status: current status of the lun |
| 75 | * @u.trig: structure zfcp_dbf_rec_trigger |
| 76 | * @u.run: structure zfcp_dbf_rec_running |
| 77 | */ |
| 78 | struct zfcp_dbf_rec { |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 79 | u8 id; |
Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 80 | char tag[ZFCP_DBF_TAG_LEN]; |
| 81 | u64 lun; |
| 82 | u64 wwpn; |
| 83 | u32 d_id; |
| 84 | u32 adapter_status; |
| 85 | u32 port_status; |
| 86 | u32 lun_status; |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 87 | union { |
Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 88 | struct zfcp_dbf_rec_trigger trig; |
| 89 | struct zfcp_dbf_rec_running run; |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 90 | } u; |
Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 91 | } __packed; |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 92 | |
Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame] | 93 | /** |
| 94 | * enum zfcp_dbf_san_id - SAN trace record identifier |
| 95 | * @ZFCP_DBF_SAN_REQ: request trace record id |
| 96 | * @ZFCP_DBF_SAN_RES: response trace record id |
| 97 | * @ZFCP_DBF_SAN_ELS: extended link service record id |
| 98 | */ |
| 99 | enum zfcp_dbf_san_id { |
| 100 | ZFCP_DBF_SAN_REQ = 1, |
| 101 | ZFCP_DBF_SAN_RES = 2, |
| 102 | ZFCP_DBF_SAN_ELS = 3, |
| 103 | }; |
| 104 | |
| 105 | /** struct zfcp_dbf_san - trace record for SAN requests and responses |
| 106 | * @id: unique number of recovery record type |
| 107 | * @tag: identifier string specifying the location of initiation |
| 108 | * @fsf_req_id: request id for fsf requests |
| 109 | * @payload: unformatted information related to request/response |
| 110 | * @d_id: destination id |
| 111 | */ |
| 112 | struct zfcp_dbf_san { |
| 113 | u8 id; |
| 114 | char tag[ZFCP_DBF_TAG_LEN]; |
| 115 | u64 fsf_req_id; |
| 116 | u32 d_id; |
| 117 | #define ZFCP_DBF_SAN_MAX_PAYLOAD (FC_CT_HDR_LEN + 32) |
| 118 | char payload[ZFCP_DBF_SAN_MAX_PAYLOAD]; |
Steffen Maier | aceeffb | 2016-08-10 18:30:53 +0200 | [diff] [blame] | 119 | u16 pl_len; |
Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame] | 120 | } __packed; |
| 121 | |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 122 | /** |
| 123 | * struct zfcp_dbf_hba_res - trace record for hba responses |
| 124 | * @req_issued: timestamp when request was issued |
| 125 | * @prot_status: protocol status |
| 126 | * @prot_status_qual: protocol status qualifier |
| 127 | * @fsf_status: fsf status |
| 128 | * @fsf_status_qual: fsf status qualifier |
| 129 | */ |
| 130 | struct zfcp_dbf_hba_res { |
| 131 | u64 req_issued; |
| 132 | u32 prot_status; |
| 133 | u8 prot_status_qual[FSF_PROT_STATUS_QUAL_SIZE]; |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 134 | u32 fsf_status; |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 135 | u8 fsf_status_qual[FSF_STATUS_QUALIFIER_SIZE]; |
Steffen Maier | 7c964ff | 2016-08-10 18:30:50 +0200 | [diff] [blame] | 136 | u32 port_handle; |
| 137 | u32 lun_handle; |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 138 | } __packed; |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 139 | |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 140 | /** |
| 141 | * struct zfcp_dbf_hba_uss - trace record for unsolicited status |
| 142 | * @status_type: type of unsolicited status |
| 143 | * @status_subtype: subtype of unsolicited status |
| 144 | * @d_id: destination ID |
| 145 | * @lun: logical unit number |
| 146 | * @queue_designator: queue designator |
| 147 | */ |
| 148 | struct zfcp_dbf_hba_uss { |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 149 | u32 status_type; |
| 150 | u32 status_subtype; |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 151 | u32 d_id; |
| 152 | u64 lun; |
| 153 | u64 queue_designator; |
| 154 | } __packed; |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 155 | |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 156 | /** |
| 157 | * enum zfcp_dbf_hba_id - HBA trace record identifier |
| 158 | * @ZFCP_DBF_HBA_RES: response trace record |
| 159 | * @ZFCP_DBF_HBA_USS: unsolicited status trace record |
| 160 | * @ZFCP_DBF_HBA_BIT: bit error trace record |
| 161 | */ |
| 162 | enum zfcp_dbf_hba_id { |
| 163 | ZFCP_DBF_HBA_RES = 1, |
| 164 | ZFCP_DBF_HBA_USS = 2, |
| 165 | ZFCP_DBF_HBA_BIT = 3, |
Steffen Maier | cb452149 | 2012-09-04 15:23:32 +0200 | [diff] [blame] | 166 | ZFCP_DBF_HBA_BASIC = 4, |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 167 | }; |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 168 | |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 169 | /** |
| 170 | * struct zfcp_dbf_hba - common trace record for HBA records |
| 171 | * @id: unique number of recovery record type |
| 172 | * @tag: identifier string specifying the location of initiation |
| 173 | * @fsf_req_id: request id for fsf requests |
| 174 | * @fsf_req_status: status of fsf request |
| 175 | * @fsf_cmd: fsf command |
| 176 | * @fsf_seq_no: fsf sequence number |
| 177 | * @pl_len: length of payload stored as zfcp_dbf_pay |
| 178 | * @u: record type specific data |
| 179 | */ |
| 180 | struct zfcp_dbf_hba { |
| 181 | u8 id; |
| 182 | char tag[ZFCP_DBF_TAG_LEN]; |
| 183 | u64 fsf_req_id; |
| 184 | u32 fsf_req_status; |
| 185 | u32 fsf_cmd; |
| 186 | u32 fsf_seq_no; |
| 187 | u16 pl_len; |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 188 | union { |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 189 | struct zfcp_dbf_hba_res res; |
| 190 | struct zfcp_dbf_hba_uss uss; |
| 191 | struct fsf_bit_error_payload be; |
Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 192 | } u; |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 193 | } __packed; |
| 194 | |
| 195 | /** |
Swen Schillig | 250a135 | 2010-12-02 15:16:15 +0100 | [diff] [blame] | 196 | * enum zfcp_dbf_scsi_id - scsi trace record identifier |
| 197 | * @ZFCP_DBF_SCSI_CMND: scsi command trace record |
| 198 | */ |
| 199 | enum zfcp_dbf_scsi_id { |
| 200 | ZFCP_DBF_SCSI_CMND = 1, |
| 201 | }; |
| 202 | |
| 203 | /** |
| 204 | * struct zfcp_dbf_scsi - common trace record for SCSI records |
| 205 | * @id: unique number of recovery record type |
| 206 | * @tag: identifier string specifying the location of initiation |
| 207 | * @scsi_id: scsi device id |
Steffen Maier | 5d4a3d0 | 2017-07-28 12:30:58 +0200 | [diff] [blame] | 208 | * @scsi_lun: scsi device logical unit number, low part of 64 bit, old 32 bit |
Swen Schillig | 250a135 | 2010-12-02 15:16:15 +0100 | [diff] [blame] | 209 | * @scsi_result: scsi result |
| 210 | * @scsi_retries: current retry number of scsi request |
| 211 | * @scsi_allowed: allowed retries |
Steffen Maier | 5b2fc2a | 2017-07-28 12:31:03 +0200 | [diff] [blame] | 212 | * @fcp_rsp_info: FCP response info code |
Swen Schillig | 250a135 | 2010-12-02 15:16:15 +0100 | [diff] [blame] | 213 | * @scsi_opcode: scsi opcode |
| 214 | * @fsf_req_id: request id of fsf request |
| 215 | * @host_scribble: LLD specific data attached to SCSI request |
Steffen Maier | 5b2fc2a | 2017-07-28 12:31:03 +0200 | [diff] [blame] | 216 | * @pl_len: length of payload stored as zfcp_dbf_pay |
| 217 | * @fcp_rsp: response for FCP request |
Steffen Maier | 5d4a3d0 | 2017-07-28 12:30:58 +0200 | [diff] [blame] | 218 | * @scsi_lun_64_hi: scsi device logical unit number, high part of 64 bit |
Swen Schillig | 250a135 | 2010-12-02 15:16:15 +0100 | [diff] [blame] | 219 | */ |
| 220 | struct zfcp_dbf_scsi { |
| 221 | u8 id; |
| 222 | char tag[ZFCP_DBF_TAG_LEN]; |
| 223 | u32 scsi_id; |
| 224 | u32 scsi_lun; |
| 225 | u32 scsi_result; |
| 226 | u8 scsi_retries; |
| 227 | u8 scsi_allowed; |
| 228 | u8 fcp_rsp_info; |
| 229 | #define ZFCP_DBF_SCSI_OPCODE 16 |
| 230 | u8 scsi_opcode[ZFCP_DBF_SCSI_OPCODE]; |
| 231 | u64 fsf_req_id; |
| 232 | u64 host_scribble; |
| 233 | u16 pl_len; |
| 234 | struct fcp_resp_with_ext fcp_rsp; |
Steffen Maier | 5d4a3d0 | 2017-07-28 12:30:58 +0200 | [diff] [blame] | 235 | u32 scsi_lun_64_hi; |
Swen Schillig | 250a135 | 2010-12-02 15:16:15 +0100 | [diff] [blame] | 236 | } __packed; |
| 237 | |
| 238 | /** |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 239 | * struct zfcp_dbf_pay - trace record for unformatted payload information |
| 240 | * @area: area this record is originated from |
| 241 | * @counter: ascending record number |
| 242 | * @fsf_req_id: request id of fsf request |
| 243 | * @data: unformatted data |
| 244 | */ |
| 245 | struct zfcp_dbf_pay { |
Swen Schillig | ea4a3a6 | 2010-12-02 15:16:16 +0100 | [diff] [blame] | 246 | u8 counter; |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 247 | char area[ZFCP_DBF_TAG_LEN]; |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 248 | u64 fsf_req_id; |
| 249 | #define ZFCP_DBF_PAY_MAX_REC 0x100 |
| 250 | char data[ZFCP_DBF_PAY_MAX_REC]; |
| 251 | } __packed; |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 252 | |
Swen Schillig | ea4a3a6 | 2010-12-02 15:16:16 +0100 | [diff] [blame] | 253 | /** |
| 254 | * struct zfcp_dbf - main dbf trace structure |
| 255 | * @pay: reference to payload trace area |
| 256 | * @rec: reference to recovery trace area |
| 257 | * @hba: reference to hba trace area |
| 258 | * @san: reference to san trace area |
| 259 | * @scsi: reference to scsi trace area |
| 260 | * @pay_lock: lock protecting payload trace buffer |
| 261 | * @rec_lock: lock protecting recovery trace buffer |
| 262 | * @hba_lock: lock protecting hba trace buffer |
| 263 | * @san_lock: lock protecting san trace buffer |
| 264 | * @scsi_lock: lock protecting scsi trace buffer |
| 265 | * @pay_buf: pre-allocated buffer for payload |
| 266 | * @rec_buf: pre-allocated buffer for recovery |
| 267 | * @hba_buf: pre-allocated buffer for hba |
| 268 | * @san_buf: pre-allocated buffer for san |
| 269 | * @scsi_buf: pre-allocated buffer for scsi |
| 270 | */ |
Christof Schmitt | d46f384 | 2009-08-18 15:43:07 +0200 | [diff] [blame] | 271 | struct zfcp_dbf { |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 272 | debug_info_t *pay; |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 273 | debug_info_t *rec; |
| 274 | debug_info_t *hba; |
| 275 | debug_info_t *san; |
| 276 | debug_info_t *scsi; |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 277 | spinlock_t pay_lock; |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 278 | spinlock_t rec_lock; |
| 279 | spinlock_t hba_lock; |
| 280 | spinlock_t san_lock; |
| 281 | spinlock_t scsi_lock; |
Swen Schillig | ea4a3a6 | 2010-12-02 15:16:16 +0100 | [diff] [blame] | 282 | struct zfcp_dbf_pay pay_buf; |
Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 283 | struct zfcp_dbf_rec rec_buf; |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 284 | struct zfcp_dbf_hba hba_buf; |
Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame] | 285 | struct zfcp_dbf_san san_buf; |
Swen Schillig | 250a135 | 2010-12-02 15:16:15 +0100 | [diff] [blame] | 286 | struct zfcp_dbf_scsi scsi_buf; |
Christof Schmitt | d46f384 | 2009-08-18 15:43:07 +0200 | [diff] [blame] | 287 | }; |
| 288 | |
Steffen Maier | 56d23ed | 2016-12-09 17:16:32 +0100 | [diff] [blame] | 289 | /** |
| 290 | * zfcp_dbf_hba_fsf_resp_suppress - true if we should not trace by default |
| 291 | * @req: request that has been completed |
| 292 | * |
| 293 | * Returns true if FCP response with only benign residual under count. |
| 294 | */ |
| 295 | static inline |
| 296 | bool zfcp_dbf_hba_fsf_resp_suppress(struct zfcp_fsf_req *req) |
| 297 | { |
| 298 | struct fsf_qtcb *qtcb = req->qtcb; |
| 299 | u32 fsf_stat = qtcb->header.fsf_status; |
| 300 | struct fcp_resp *fcp_rsp; |
| 301 | u8 rsp_flags, fr_status; |
| 302 | |
| 303 | if (qtcb->prefix.qtcb_type != FSF_IO_COMMAND) |
| 304 | return false; /* not an FCP response */ |
Steffen Maier | df00d7b | 2017-07-28 12:31:01 +0200 | [diff] [blame] | 305 | fcp_rsp = &qtcb->bottom.io.fcp_rsp.iu.resp; |
Steffen Maier | 56d23ed | 2016-12-09 17:16:32 +0100 | [diff] [blame] | 306 | rsp_flags = fcp_rsp->fr_flags; |
| 307 | fr_status = fcp_rsp->fr_status; |
| 308 | return (fsf_stat == FSF_FCP_RSP_AVAILABLE) && |
| 309 | (rsp_flags == FCP_RESID_UNDER) && |
| 310 | (fr_status == SAM_STAT_GOOD); |
| 311 | } |
| 312 | |
Christof Schmitt | dcd20e2 | 2009-08-18 15:43:08 +0200 | [diff] [blame] | 313 | static inline |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 314 | void zfcp_dbf_hba_fsf_resp(char *tag, int level, struct zfcp_fsf_req *req) |
Christof Schmitt | 2e261af | 2009-08-18 15:43:09 +0200 | [diff] [blame] | 315 | { |
Hendrik Brueckner | 8e6a828 | 2013-09-18 17:21:34 +0200 | [diff] [blame] | 316 | if (debug_level_enabled(req->adapter->dbf->hba, level)) |
Steffen Maier | 35f040d | 2016-08-10 18:30:47 +0200 | [diff] [blame] | 317 | zfcp_dbf_hba_fsf_res(tag, level, req); |
Christof Schmitt | 2e261af | 2009-08-18 15:43:09 +0200 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | /** |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 321 | * zfcp_dbf_hba_fsf_response - trace event for request completion |
Swen Schillig | 250a135 | 2010-12-02 15:16:15 +0100 | [diff] [blame] | 322 | * @req: request that has been completed |
Christof Schmitt | 2e261af | 2009-08-18 15:43:09 +0200 | [diff] [blame] | 323 | */ |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 324 | static inline |
| 325 | void zfcp_dbf_hba_fsf_response(struct zfcp_fsf_req *req) |
Christof Schmitt | 2e261af | 2009-08-18 15:43:09 +0200 | [diff] [blame] | 326 | { |
Christof Schmitt | 2e261af | 2009-08-18 15:43:09 +0200 | [diff] [blame] | 327 | struct fsf_qtcb *qtcb = req->qtcb; |
| 328 | |
Steffen Maier | fdb7cee | 2017-07-28 12:30:57 +0200 | [diff] [blame] | 329 | if (unlikely(req->status & (ZFCP_STATUS_FSFREQ_DISMISSED | |
| 330 | ZFCP_STATUS_FSFREQ_ERROR))) { |
| 331 | zfcp_dbf_hba_fsf_resp("fs_rerr", 3, req); |
| 332 | |
| 333 | } else if ((qtcb->prefix.prot_status != FSF_PROT_GOOD) && |
Christof Schmitt | 2e261af | 2009-08-18 15:43:09 +0200 | [diff] [blame] | 334 | (qtcb->prefix.prot_status != FSF_PROT_FSF_STATUS_PRESENTED)) { |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 335 | zfcp_dbf_hba_fsf_resp("fs_perr", 1, req); |
Christof Schmitt | 2e261af | 2009-08-18 15:43:09 +0200 | [diff] [blame] | 336 | |
| 337 | } else if (qtcb->header.fsf_status != FSF_GOOD) { |
Steffen Maier | 56d23ed | 2016-12-09 17:16:32 +0100 | [diff] [blame] | 338 | zfcp_dbf_hba_fsf_resp("fs_ferr", |
| 339 | zfcp_dbf_hba_fsf_resp_suppress(req) |
| 340 | ? 5 : 1, req); |
Christof Schmitt | 2e261af | 2009-08-18 15:43:09 +0200 | [diff] [blame] | 341 | |
| 342 | } else if ((req->fsf_command == FSF_QTCB_OPEN_PORT_WITH_DID) || |
| 343 | (req->fsf_command == FSF_QTCB_OPEN_LUN)) { |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 344 | zfcp_dbf_hba_fsf_resp("fs_open", 4, req); |
Christof Schmitt | 2e261af | 2009-08-18 15:43:09 +0200 | [diff] [blame] | 345 | |
| 346 | } else if (qtcb->header.log_length) { |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 347 | zfcp_dbf_hba_fsf_resp("fs_qtcb", 5, req); |
Christof Schmitt | 2e261af | 2009-08-18 15:43:09 +0200 | [diff] [blame] | 348 | |
| 349 | } else { |
Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 350 | zfcp_dbf_hba_fsf_resp("fs_norm", 6, req); |
Christof Schmitt | 2e261af | 2009-08-18 15:43:09 +0200 | [diff] [blame] | 351 | } |
Christof Schmitt | 2e261af | 2009-08-18 15:43:09 +0200 | [diff] [blame] | 352 | } |
| 353 | |
| 354 | static inline |
Swen Schillig | 250a135 | 2010-12-02 15:16:15 +0100 | [diff] [blame] | 355 | void _zfcp_dbf_scsi(char *tag, int level, struct scsi_cmnd *scmd, |
| 356 | struct zfcp_fsf_req *req) |
Christof Schmitt | dcd20e2 | 2009-08-18 15:43:08 +0200 | [diff] [blame] | 357 | { |
Swen Schillig | 250a135 | 2010-12-02 15:16:15 +0100 | [diff] [blame] | 358 | struct zfcp_adapter *adapter = (struct zfcp_adapter *) |
| 359 | scmd->device->host->hostdata[0]; |
| 360 | |
Hendrik Brueckner | 8e6a828 | 2013-09-18 17:21:34 +0200 | [diff] [blame] | 361 | if (debug_level_enabled(adapter->dbf->scsi, level)) |
Steffen Maier | 8221211 | 2018-05-17 19:14:50 +0200 | [diff] [blame] | 362 | zfcp_dbf_scsi_common(tag, level, scmd->device, scmd, req); |
Christof Schmitt | dcd20e2 | 2009-08-18 15:43:08 +0200 | [diff] [blame] | 363 | } |
| 364 | |
| 365 | /** |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 366 | * zfcp_dbf_scsi_result - trace event for SCSI command completion |
Christof Schmitt | dcd20e2 | 2009-08-18 15:43:08 +0200 | [diff] [blame] | 367 | * @scmd: SCSI command pointer |
Christof Schmitt | ab72528 | 2010-02-17 11:18:57 +0100 | [diff] [blame] | 368 | * @req: FSF request used to issue SCSI command |
Christof Schmitt | dcd20e2 | 2009-08-18 15:43:08 +0200 | [diff] [blame] | 369 | */ |
| 370 | static inline |
Swen Schillig | 250a135 | 2010-12-02 15:16:15 +0100 | [diff] [blame] | 371 | void zfcp_dbf_scsi_result(struct scsi_cmnd *scmd, struct zfcp_fsf_req *req) |
Christof Schmitt | dcd20e2 | 2009-08-18 15:43:08 +0200 | [diff] [blame] | 372 | { |
Christof Schmitt | ab72528 | 2010-02-17 11:18:57 +0100 | [diff] [blame] | 373 | if (scmd->result != 0) |
Swen Schillig | 250a135 | 2010-12-02 15:16:15 +0100 | [diff] [blame] | 374 | _zfcp_dbf_scsi("rsl_err", 3, scmd, req); |
Christof Schmitt | ab72528 | 2010-02-17 11:18:57 +0100 | [diff] [blame] | 375 | else if (scmd->retries > 0) |
Swen Schillig | 250a135 | 2010-12-02 15:16:15 +0100 | [diff] [blame] | 376 | _zfcp_dbf_scsi("rsl_ret", 4, scmd, req); |
Christof Schmitt | ab72528 | 2010-02-17 11:18:57 +0100 | [diff] [blame] | 377 | else |
Swen Schillig | 250a135 | 2010-12-02 15:16:15 +0100 | [diff] [blame] | 378 | _zfcp_dbf_scsi("rsl_nor", 6, scmd, req); |
Christof Schmitt | ab72528 | 2010-02-17 11:18:57 +0100 | [diff] [blame] | 379 | } |
| 380 | |
| 381 | /** |
| 382 | * zfcp_dbf_scsi_fail_send - trace event for failure to send SCSI command |
Christof Schmitt | ab72528 | 2010-02-17 11:18:57 +0100 | [diff] [blame] | 383 | * @scmd: SCSI command pointer |
| 384 | */ |
| 385 | static inline |
Swen Schillig | 250a135 | 2010-12-02 15:16:15 +0100 | [diff] [blame] | 386 | void zfcp_dbf_scsi_fail_send(struct scsi_cmnd *scmd) |
Christof Schmitt | ab72528 | 2010-02-17 11:18:57 +0100 | [diff] [blame] | 387 | { |
Swen Schillig | 250a135 | 2010-12-02 15:16:15 +0100 | [diff] [blame] | 388 | _zfcp_dbf_scsi("rsl_fai", 4, scmd, NULL); |
Christof Schmitt | dcd20e2 | 2009-08-18 15:43:08 +0200 | [diff] [blame] | 389 | } |
| 390 | |
| 391 | /** |
Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 392 | * zfcp_dbf_scsi_abort - trace event for SCSI command abort |
Christof Schmitt | dcd20e2 | 2009-08-18 15:43:08 +0200 | [diff] [blame] | 393 | * @tag: tag indicating success or failure of abort operation |
Christof Schmitt | dcd20e2 | 2009-08-18 15:43:08 +0200 | [diff] [blame] | 394 | * @scmd: SCSI command to be aborted |
Swen Schillig | 250a135 | 2010-12-02 15:16:15 +0100 | [diff] [blame] | 395 | * @fsf_req: request containing abort (might be NULL) |
Christof Schmitt | dcd20e2 | 2009-08-18 15:43:08 +0200 | [diff] [blame] | 396 | */ |
| 397 | static inline |
Swen Schillig | 250a135 | 2010-12-02 15:16:15 +0100 | [diff] [blame] | 398 | void zfcp_dbf_scsi_abort(char *tag, struct scsi_cmnd *scmd, |
| 399 | struct zfcp_fsf_req *fsf_req) |
Christof Schmitt | dcd20e2 | 2009-08-18 15:43:08 +0200 | [diff] [blame] | 400 | { |
Swen Schillig | 250a135 | 2010-12-02 15:16:15 +0100 | [diff] [blame] | 401 | _zfcp_dbf_scsi(tag, 1, scmd, fsf_req); |
Christof Schmitt | dcd20e2 | 2009-08-18 15:43:08 +0200 | [diff] [blame] | 402 | } |
| 403 | |
| 404 | /** |
Steffen Maier | 8221211 | 2018-05-17 19:14:50 +0200 | [diff] [blame] | 405 | * zfcp_dbf_scsi_devreset() - Trace event for Logical Unit or Target Reset. |
| 406 | * @tag: Tag indicating success or failure of reset operation. |
| 407 | * @sdev: Pointer to SCSI device as context for this event. |
| 408 | * @flag: Indicates type of reset (Target Reset, Logical Unit Reset). |
| 409 | * @fsf_req: Pointer to FSF request representing the TMF, or NULL. |
Christof Schmitt | dcd20e2 | 2009-08-18 15:43:08 +0200 | [diff] [blame] | 410 | */ |
| 411 | static inline |
Steffen Maier | 8221211 | 2018-05-17 19:14:50 +0200 | [diff] [blame] | 412 | void zfcp_dbf_scsi_devreset(char *tag, struct scsi_device *sdev, u8 flag, |
Steffen Maier | 9fe5d2b | 2017-07-28 12:30:54 +0200 | [diff] [blame] | 413 | struct zfcp_fsf_req *fsf_req) |
Christof Schmitt | dcd20e2 | 2009-08-18 15:43:08 +0200 | [diff] [blame] | 414 | { |
Steffen Maier | 8221211 | 2018-05-17 19:14:50 +0200 | [diff] [blame] | 415 | struct zfcp_adapter *adapter = (struct zfcp_adapter *) |
| 416 | sdev->host->hostdata[0]; |
Swen Schillig | 250a135 | 2010-12-02 15:16:15 +0100 | [diff] [blame] | 417 | char tmp_tag[ZFCP_DBF_TAG_LEN]; |
Steffen Maier | 8221211 | 2018-05-17 19:14:50 +0200 | [diff] [blame] | 418 | static int const level = 1; |
| 419 | |
| 420 | if (unlikely(!debug_level_enabled(adapter->dbf->scsi, level))) |
| 421 | return; |
Christof Schmitt | b62a8d9 | 2010-09-08 14:39:55 +0200 | [diff] [blame] | 422 | |
Swen Schillig | 250a135 | 2010-12-02 15:16:15 +0100 | [diff] [blame] | 423 | if (flag == FCP_TMF_TGT_RESET) |
| 424 | memcpy(tmp_tag, "tr_", 3); |
| 425 | else |
| 426 | memcpy(tmp_tag, "lr_", 3); |
| 427 | |
| 428 | memcpy(&tmp_tag[3], tag, 4); |
Steffen Maier | 8221211 | 2018-05-17 19:14:50 +0200 | [diff] [blame] | 429 | zfcp_dbf_scsi_common(tmp_tag, level, sdev, NULL, fsf_req); |
Christof Schmitt | dcd20e2 | 2009-08-18 15:43:08 +0200 | [diff] [blame] | 430 | } |
| 431 | |
Benjamin Block | dac37e1 | 2016-12-09 17:16:31 +0100 | [diff] [blame] | 432 | /** |
| 433 | * zfcp_dbf_scsi_nullcmnd() - trace NULLify of SCSI command in dev/tgt-reset. |
| 434 | * @scmnd: SCSI command that was NULLified. |
| 435 | * @fsf_req: request that owned @scmnd. |
| 436 | */ |
| 437 | static inline void zfcp_dbf_scsi_nullcmnd(struct scsi_cmnd *scmnd, |
| 438 | struct zfcp_fsf_req *fsf_req) |
| 439 | { |
| 440 | _zfcp_dbf_scsi("scfc__1", 3, scmnd, fsf_req); |
| 441 | } |
| 442 | |
Christof Schmitt | 2b604c9 | 2008-03-31 11:15:28 +0200 | [diff] [blame] | 443 | #endif /* ZFCP_DBF_H */ |