0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef ZFCP_DBF_H
0010 #define ZFCP_DBF_H
0011
0012 #include <scsi/fc/fc_fcp.h>
0013 #include "zfcp_ext.h"
0014 #include "zfcp_fsf.h"
0015 #include "zfcp_def.h"
0016
0017 #define ZFCP_DBF_TAG_LEN 7
0018
0019 #define ZFCP_DBF_INVALID_WWPN 0x0000000000000000ull
0020 #define ZFCP_DBF_INVALID_LUN 0xFFFFFFFFFFFFFFFFull
0021
0022 enum zfcp_dbf_pseudo_erp_act_type {
0023 ZFCP_PSEUDO_ERP_ACTION_RPORT_ADD = 0xff,
0024 ZFCP_PSEUDO_ERP_ACTION_RPORT_DEL = 0xfe,
0025 };
0026
0027
0028
0029
0030
0031
0032
0033
0034 struct zfcp_dbf_rec_trigger {
0035 u32 ready;
0036 u32 running;
0037 u8 want;
0038 u8 need;
0039 } __packed;
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049 struct zfcp_dbf_rec_running {
0050 u64 fsf_req_id;
0051 u32 rec_status;
0052 u16 rec_step;
0053 u8 rec_action;
0054 u8 rec_count;
0055 } __packed;
0056
0057
0058
0059
0060
0061
0062 enum zfcp_dbf_rec_id {
0063 ZFCP_DBF_REC_TRIG = 1,
0064 ZFCP_DBF_REC_RUN = 2,
0065 };
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081 struct zfcp_dbf_rec {
0082 u8 id;
0083 char tag[ZFCP_DBF_TAG_LEN];
0084 u64 lun;
0085 u64 wwpn;
0086 u32 d_id;
0087 u32 adapter_status;
0088 u32 port_status;
0089 u32 lun_status;
0090 union {
0091 struct zfcp_dbf_rec_trigger trig;
0092 struct zfcp_dbf_rec_running run;
0093 } u;
0094 } __packed;
0095
0096
0097
0098
0099
0100
0101
0102 enum zfcp_dbf_san_id {
0103 ZFCP_DBF_SAN_REQ = 1,
0104 ZFCP_DBF_SAN_RES = 2,
0105 ZFCP_DBF_SAN_ELS = 3,
0106 };
0107
0108
0109
0110
0111
0112
0113
0114
0115 struct zfcp_dbf_san {
0116 u8 id;
0117 char tag[ZFCP_DBF_TAG_LEN];
0118 u64 fsf_req_id;
0119 u32 d_id;
0120 #define ZFCP_DBF_SAN_MAX_PAYLOAD (FC_CT_HDR_LEN + 32)
0121 char payload[ZFCP_DBF_SAN_MAX_PAYLOAD];
0122 u16 pl_len;
0123 } __packed;
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135 struct zfcp_dbf_hba_res {
0136 u64 req_issued;
0137 u32 prot_status;
0138 u8 prot_status_qual[FSF_PROT_STATUS_QUAL_SIZE];
0139 u32 fsf_status;
0140 u8 fsf_status_qual[FSF_STATUS_QUALIFIER_SIZE];
0141 u32 port_handle;
0142 u32 lun_handle;
0143 } __packed;
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153 struct zfcp_dbf_hba_uss {
0154 u32 status_type;
0155 u32 status_subtype;
0156 u32 d_id;
0157 u64 lun;
0158 u64 queue_designator;
0159 } __packed;
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171 struct zfcp_dbf_hba_fces {
0172 u64 req_issued;
0173 u32 fsf_status;
0174 u32 port_handle;
0175 u64 wwpn;
0176 u32 fc_security_old;
0177 u32 fc_security_new;
0178 } __packed;
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188 enum zfcp_dbf_hba_id {
0189 ZFCP_DBF_HBA_RES = 1,
0190 ZFCP_DBF_HBA_USS = 2,
0191 ZFCP_DBF_HBA_BIT = 3,
0192 ZFCP_DBF_HBA_BASIC = 4,
0193 ZFCP_DBF_HBA_FCES = 5,
0194 };
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211 struct zfcp_dbf_hba {
0212 u8 id;
0213 char tag[ZFCP_DBF_TAG_LEN];
0214 u64 fsf_req_id;
0215 u32 fsf_req_status;
0216 u32 fsf_cmd;
0217 u32 fsf_seq_no;
0218 u16 pl_len;
0219 union {
0220 struct zfcp_dbf_hba_res res;
0221 struct zfcp_dbf_hba_uss uss;
0222 struct fsf_bit_error_payload be;
0223 struct zfcp_dbf_hba_fces fces;
0224 } u;
0225 } __packed;
0226
0227
0228
0229
0230
0231 enum zfcp_dbf_scsi_id {
0232 ZFCP_DBF_SCSI_CMND = 1,
0233 };
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243
0244
0245
0246
0247
0248
0249
0250
0251
0252 struct zfcp_dbf_scsi {
0253 u8 id;
0254 char tag[ZFCP_DBF_TAG_LEN];
0255 u32 scsi_id;
0256 u32 scsi_lun;
0257 u32 scsi_result;
0258 u8 scsi_retries;
0259 u8 scsi_allowed;
0260 u8 fcp_rsp_info;
0261 #define ZFCP_DBF_SCSI_OPCODE 16
0262 u8 scsi_opcode[ZFCP_DBF_SCSI_OPCODE];
0263 u64 fsf_req_id;
0264 u64 host_scribble;
0265 u16 pl_len;
0266 struct fcp_resp_with_ext fcp_rsp;
0267 u32 scsi_lun_64_hi;
0268 } __packed;
0269
0270
0271
0272
0273
0274
0275
0276
0277 struct zfcp_dbf_pay {
0278 u8 counter;
0279 char area[ZFCP_DBF_TAG_LEN];
0280 u64 fsf_req_id;
0281 #define ZFCP_DBF_PAY_MAX_REC 0x100
0282 char data[ZFCP_DBF_PAY_MAX_REC];
0283 } __packed;
0284
0285
0286
0287
0288
0289
0290
0291
0292
0293
0294
0295
0296
0297
0298
0299
0300
0301
0302
0303 struct zfcp_dbf {
0304 debug_info_t *pay;
0305 debug_info_t *rec;
0306 debug_info_t *hba;
0307 debug_info_t *san;
0308 debug_info_t *scsi;
0309 spinlock_t pay_lock;
0310 spinlock_t rec_lock;
0311 spinlock_t hba_lock;
0312 spinlock_t san_lock;
0313 spinlock_t scsi_lock;
0314 struct zfcp_dbf_pay pay_buf;
0315 struct zfcp_dbf_rec rec_buf;
0316 struct zfcp_dbf_hba hba_buf;
0317 struct zfcp_dbf_san san_buf;
0318 struct zfcp_dbf_scsi scsi_buf;
0319 };
0320
0321
0322
0323
0324
0325
0326
0327 static inline
0328 bool zfcp_dbf_hba_fsf_resp_suppress(struct zfcp_fsf_req *req)
0329 {
0330 struct fsf_qtcb *qtcb = req->qtcb;
0331 u32 fsf_stat = qtcb->header.fsf_status;
0332 struct fcp_resp *fcp_rsp;
0333 u8 rsp_flags, fr_status;
0334
0335 if (qtcb->prefix.qtcb_type != FSF_IO_COMMAND)
0336 return false;
0337 fcp_rsp = &qtcb->bottom.io.fcp_rsp.iu.resp;
0338 rsp_flags = fcp_rsp->fr_flags;
0339 fr_status = fcp_rsp->fr_status;
0340 return (fsf_stat == FSF_FCP_RSP_AVAILABLE) &&
0341 (rsp_flags == FCP_RESID_UNDER) &&
0342 (fr_status == SAM_STAT_GOOD);
0343 }
0344
0345 static inline
0346 void zfcp_dbf_hba_fsf_resp(char *tag, int level, struct zfcp_fsf_req *req)
0347 {
0348 if (debug_level_enabled(req->adapter->dbf->hba, level))
0349 zfcp_dbf_hba_fsf_res(tag, level, req);
0350 }
0351
0352
0353
0354
0355
0356 static inline
0357 void zfcp_dbf_hba_fsf_response(struct zfcp_fsf_req *req)
0358 {
0359 struct fsf_qtcb *qtcb = req->qtcb;
0360
0361 if (unlikely(req->status & (ZFCP_STATUS_FSFREQ_DISMISSED |
0362 ZFCP_STATUS_FSFREQ_ERROR))) {
0363 zfcp_dbf_hba_fsf_resp("fs_rerr", 3, req);
0364
0365 } else if ((qtcb->prefix.prot_status != FSF_PROT_GOOD) &&
0366 (qtcb->prefix.prot_status != FSF_PROT_FSF_STATUS_PRESENTED)) {
0367 zfcp_dbf_hba_fsf_resp("fs_perr", 1, req);
0368
0369 } else if (qtcb->header.fsf_status != FSF_GOOD) {
0370 zfcp_dbf_hba_fsf_resp("fs_ferr",
0371 zfcp_dbf_hba_fsf_resp_suppress(req)
0372 ? 5 : 1, req);
0373
0374 } else if ((qtcb->header.fsf_command == FSF_QTCB_OPEN_PORT_WITH_DID) ||
0375 (qtcb->header.fsf_command == FSF_QTCB_OPEN_LUN)) {
0376 zfcp_dbf_hba_fsf_resp("fs_open", 4, req);
0377
0378 } else if (qtcb->header.log_length) {
0379 zfcp_dbf_hba_fsf_resp("fs_qtcb", 5, req);
0380
0381 } else {
0382 zfcp_dbf_hba_fsf_resp("fs_norm", 6, req);
0383 }
0384 }
0385
0386 static inline
0387 void _zfcp_dbf_scsi(char *tag, int level, struct scsi_cmnd *scmd,
0388 struct zfcp_fsf_req *req)
0389 {
0390 struct zfcp_adapter *adapter = (struct zfcp_adapter *)
0391 scmd->device->host->hostdata[0];
0392
0393 if (debug_level_enabled(adapter->dbf->scsi, level))
0394 zfcp_dbf_scsi_common(tag, level, scmd->device, scmd, req);
0395 }
0396
0397
0398
0399
0400
0401
0402 static inline
0403 void zfcp_dbf_scsi_result(struct scsi_cmnd *scmd, struct zfcp_fsf_req *req)
0404 {
0405 if (scmd->result != 0)
0406 _zfcp_dbf_scsi("rsl_err", 3, scmd, req);
0407 else if (scmd->retries > 0)
0408 _zfcp_dbf_scsi("rsl_ret", 4, scmd, req);
0409 else
0410 _zfcp_dbf_scsi("rsl_nor", 6, scmd, req);
0411 }
0412
0413
0414
0415
0416
0417 static inline
0418 void zfcp_dbf_scsi_fail_send(struct scsi_cmnd *scmd)
0419 {
0420 _zfcp_dbf_scsi("rsl_fai", 4, scmd, NULL);
0421 }
0422
0423
0424
0425
0426
0427
0428
0429 static inline
0430 void zfcp_dbf_scsi_abort(char *tag, struct scsi_cmnd *scmd,
0431 struct zfcp_fsf_req *fsf_req)
0432 {
0433 _zfcp_dbf_scsi(tag, 1, scmd, fsf_req);
0434 }
0435
0436
0437
0438
0439
0440
0441
0442
0443 static inline
0444 void zfcp_dbf_scsi_devreset(char *tag, struct scsi_device *sdev, u8 flag,
0445 struct zfcp_fsf_req *fsf_req)
0446 {
0447 struct zfcp_adapter *adapter = (struct zfcp_adapter *)
0448 sdev->host->hostdata[0];
0449 char tmp_tag[ZFCP_DBF_TAG_LEN];
0450 static int const level = 1;
0451
0452 if (unlikely(!debug_level_enabled(adapter->dbf->scsi, level)))
0453 return;
0454
0455 if (flag == FCP_TMF_TGT_RESET)
0456 memcpy(tmp_tag, "tr_", 3);
0457 else
0458 memcpy(tmp_tag, "lr_", 3);
0459
0460 memcpy(&tmp_tag[3], tag, 4);
0461 zfcp_dbf_scsi_common(tmp_tag, level, sdev, NULL, fsf_req);
0462 }
0463
0464
0465
0466
0467
0468
0469 static inline void zfcp_dbf_scsi_nullcmnd(struct scsi_cmnd *scmnd,
0470 struct zfcp_fsf_req *fsf_req)
0471 {
0472 _zfcp_dbf_scsi("scfc__1", 3, scmnd, fsf_req);
0473 }
0474
0475 #endif