Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * zfcp device driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Debug traces for zfcp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * Copyright IBM Corp. 2002, 2020
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #define KMSG_COMPONENT "zfcp"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/ctype.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <asm/debug.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include "zfcp_dbf.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include "zfcp_ext.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include "zfcp_fc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) static u32 dbfsize = 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) module_param(dbfsize, uint, 0400);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) MODULE_PARM_DESC(dbfsize,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 		 "number of pages for each debug feature area (default 4)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) static u32 dbflevel = 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) module_param(dbflevel, uint, 0400);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) MODULE_PARM_DESC(dbflevel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 		 "log level for each debug feature area "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 		 "(default 3, range 0..6)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) static inline unsigned int zfcp_dbf_plen(unsigned int offset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	return sizeof(struct zfcp_dbf_pay) + offset - ZFCP_DBF_PAY_MAX_REC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) void zfcp_dbf_pl_write(struct zfcp_dbf *dbf, void *data, u16 length, char *area,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 		       u64 req_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	struct zfcp_dbf_pay *pl = &dbf->pay_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	u16 offset = 0, rec_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	spin_lock(&dbf->pay_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	memset(pl, 0, sizeof(*pl));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	pl->fsf_req_id = req_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	memcpy(pl->area, area, ZFCP_DBF_TAG_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	while (offset < length) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 		rec_length = min((u16) ZFCP_DBF_PAY_MAX_REC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 				 (u16) (length - offset));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 		memcpy(pl->data, data + offset, rec_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 		debug_event(dbf->pay, 1, pl, zfcp_dbf_plen(rec_length));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 		offset += rec_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 		pl->counter++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	spin_unlock(&dbf->pay_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65)  * zfcp_dbf_hba_fsf_res - trace event for fsf responses
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66)  * @tag: tag indicating which kind of FSF response has been received
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67)  * @level: trace level to be used for event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68)  * @req: request for which a response was received
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) void zfcp_dbf_hba_fsf_res(char *tag, int level, struct zfcp_fsf_req *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	struct zfcp_dbf *dbf = req->adapter->dbf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	struct fsf_qtcb_prefix *q_pref = &req->qtcb->prefix;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	struct fsf_qtcb_header *q_head = &req->qtcb->header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	struct zfcp_dbf_hba *rec = &dbf->hba_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	spin_lock_irqsave(&dbf->hba_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	memset(rec, 0, sizeof(*rec));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	rec->id = ZFCP_DBF_HBA_RES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	rec->fsf_req_id = req->req_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	rec->fsf_req_status = req->status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	rec->fsf_cmd = q_head->fsf_command;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	rec->fsf_seq_no = q_pref->req_seq_no;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	rec->u.res.req_issued = req->issued;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	rec->u.res.prot_status = q_pref->prot_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	rec->u.res.fsf_status = q_head->fsf_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	rec->u.res.port_handle = q_head->port_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	rec->u.res.lun_handle = q_head->lun_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	memcpy(rec->u.res.prot_status_qual, &q_pref->prot_status_qual,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	       FSF_PROT_STATUS_QUAL_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	memcpy(rec->u.res.fsf_status_qual, &q_head->fsf_status_qual,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	       FSF_STATUS_QUALIFIER_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	rec->pl_len = q_head->log_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	zfcp_dbf_pl_write(dbf, (char *)q_pref + q_head->log_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 			  rec->pl_len, "fsf_res", req->req_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	debug_event(dbf->hba, level, rec, sizeof(*rec));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	spin_unlock_irqrestore(&dbf->hba_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)  * zfcp_dbf_hba_fsf_fces - trace event for fsf responses related to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)  *			   FC Endpoint Security (FCES)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)  * @tag: tag indicating which kind of FC Endpoint Security event has occurred
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)  * @req: request for which a response was received
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)  * @wwpn: remote port or ZFCP_DBF_INVALID_WWPN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)  * @fc_security_old: old FC Endpoint Security of FCP device or connection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)  * @fc_security_new: new FC Endpoint Security of FCP device or connection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) void zfcp_dbf_hba_fsf_fces(char *tag, const struct zfcp_fsf_req *req, u64 wwpn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 			   u32 fc_security_old, u32 fc_security_new)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	struct zfcp_dbf *dbf = req->adapter->dbf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	struct fsf_qtcb_prefix *q_pref = &req->qtcb->prefix;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	struct fsf_qtcb_header *q_head = &req->qtcb->header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	struct zfcp_dbf_hba *rec = &dbf->hba_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	static int const level = 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	if (unlikely(!debug_level_enabled(dbf->hba, level)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	spin_lock_irqsave(&dbf->hba_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	memset(rec, 0, sizeof(*rec));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	rec->id = ZFCP_DBF_HBA_FCES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	rec->fsf_req_id = req->req_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	rec->fsf_req_status = req->status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	rec->fsf_cmd = q_head->fsf_command;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	rec->fsf_seq_no = q_pref->req_seq_no;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	rec->u.fces.req_issued = req->issued;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	rec->u.fces.fsf_status = q_head->fsf_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	rec->u.fces.port_handle = q_head->port_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	rec->u.fces.wwpn = wwpn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	rec->u.fces.fc_security_old = fc_security_old;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	rec->u.fces.fc_security_new = fc_security_new;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	debug_event(dbf->hba, level, rec, sizeof(*rec));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	spin_unlock_irqrestore(&dbf->hba_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)  * zfcp_dbf_hba_fsf_uss - trace event for an unsolicited status buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)  * @tag: tag indicating which kind of unsolicited status has been received
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)  * @req: request providing the unsolicited status
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) void zfcp_dbf_hba_fsf_uss(char *tag, struct zfcp_fsf_req *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	struct zfcp_dbf *dbf = req->adapter->dbf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	struct fsf_status_read_buffer *srb = req->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	struct zfcp_dbf_hba *rec = &dbf->hba_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	static int const level = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	if (unlikely(!debug_level_enabled(dbf->hba, level)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	spin_lock_irqsave(&dbf->hba_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	memset(rec, 0, sizeof(*rec));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	rec->id = ZFCP_DBF_HBA_USS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	rec->fsf_req_id = req->req_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	rec->fsf_req_status = req->status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	rec->fsf_cmd = FSF_QTCB_UNSOLICITED_STATUS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	if (!srb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		goto log;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	rec->u.uss.status_type = srb->status_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	rec->u.uss.status_subtype = srb->status_subtype;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	rec->u.uss.d_id = ntoh24(srb->d_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	rec->u.uss.lun = srb->fcp_lun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	memcpy(&rec->u.uss.queue_designator, &srb->queue_designator,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	       sizeof(rec->u.uss.queue_designator));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	/* status read buffer payload length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	rec->pl_len = (!srb->length) ? 0 : srb->length -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 			offsetof(struct fsf_status_read_buffer, payload);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	if (rec->pl_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		zfcp_dbf_pl_write(dbf, srb->payload.data, rec->pl_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 				  "fsf_uss", req->req_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) log:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	debug_event(dbf->hba, level, rec, sizeof(*rec));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	spin_unlock_irqrestore(&dbf->hba_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)  * zfcp_dbf_hba_bit_err - trace event for bit error conditions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)  * @tag: tag indicating which kind of bit error unsolicited status was received
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)  * @req: request which caused the bit_error condition
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) void zfcp_dbf_hba_bit_err(char *tag, struct zfcp_fsf_req *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	struct zfcp_dbf *dbf = req->adapter->dbf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	struct zfcp_dbf_hba *rec = &dbf->hba_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	struct fsf_status_read_buffer *sr_buf = req->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	static int const level = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	if (unlikely(!debug_level_enabled(dbf->hba, level)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	spin_lock_irqsave(&dbf->hba_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	memset(rec, 0, sizeof(*rec));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	rec->id = ZFCP_DBF_HBA_BIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	rec->fsf_req_id = req->req_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	rec->fsf_req_status = req->status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	rec->fsf_cmd = FSF_QTCB_UNSOLICITED_STATUS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	memcpy(&rec->u.be, &sr_buf->payload.bit_error,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	       sizeof(struct fsf_bit_error_payload));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	debug_event(dbf->hba, level, rec, sizeof(*rec));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	spin_unlock_irqrestore(&dbf->hba_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)  * zfcp_dbf_hba_def_err - trace event for deferred error messages
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)  * @adapter: pointer to struct zfcp_adapter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)  * @req_id: request id which caused the deferred error message
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)  * @scount: number of sbals incl. the signaling sbal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)  * @pl: array of all involved sbals
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) void zfcp_dbf_hba_def_err(struct zfcp_adapter *adapter, u64 req_id, u16 scount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 			  void **pl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	struct zfcp_dbf *dbf = adapter->dbf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	struct zfcp_dbf_pay *payload = &dbf->pay_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	static int const level = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	u16 length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	if (unlikely(!debug_level_enabled(dbf->pay, level)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	if (!pl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	spin_lock_irqsave(&dbf->pay_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	memset(payload, 0, sizeof(*payload));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	memcpy(payload->area, "def_err", 7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	payload->fsf_req_id = req_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	payload->counter = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	length = min((u16)sizeof(struct qdio_buffer),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 		     (u16)ZFCP_DBF_PAY_MAX_REC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	while (payload->counter < scount && (char *)pl[payload->counter]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 		memcpy(payload->data, (char *)pl[payload->counter], length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 		debug_event(dbf->pay, level, payload, zfcp_dbf_plen(length));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 		payload->counter++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	spin_unlock_irqrestore(&dbf->pay_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)  * zfcp_dbf_hba_basic - trace event for basic adapter events
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)  * @tag: identifier for event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)  * @adapter: pointer to struct zfcp_adapter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) void zfcp_dbf_hba_basic(char *tag, struct zfcp_adapter *adapter)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	struct zfcp_dbf *dbf = adapter->dbf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	struct zfcp_dbf_hba *rec = &dbf->hba_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	static int const level = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	if (unlikely(!debug_level_enabled(dbf->hba, level)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	spin_lock_irqsave(&dbf->hba_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	memset(rec, 0, sizeof(*rec));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	rec->id = ZFCP_DBF_HBA_BASIC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	debug_event(dbf->hba, level, rec, sizeof(*rec));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	spin_unlock_irqrestore(&dbf->hba_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) static void zfcp_dbf_set_common(struct zfcp_dbf_rec *rec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 				struct zfcp_adapter *adapter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 				struct zfcp_port *port,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 				struct scsi_device *sdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	rec->adapter_status = atomic_read(&adapter->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	if (port) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 		rec->port_status = atomic_read(&port->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 		rec->wwpn = port->wwpn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 		rec->d_id = port->d_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	if (sdev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 		rec->lun_status = atomic_read(&sdev_to_zfcp(sdev)->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 		rec->lun = zfcp_scsi_dev_lun(sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 		rec->lun = ZFCP_DBF_INVALID_LUN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310)  * zfcp_dbf_rec_trig - trace event related to triggered recovery
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311)  * @tag: identifier for event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)  * @adapter: adapter on which the erp_action should run
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313)  * @port: remote port involved in the erp_action
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314)  * @sdev: scsi device involved in the erp_action
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)  * @want: wanted erp_action
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316)  * @need: required erp_action
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318)  * The adapter->erp_lock has to be held.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) void zfcp_dbf_rec_trig(char *tag, struct zfcp_adapter *adapter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 		       struct zfcp_port *port, struct scsi_device *sdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 		       u8 want, u8 need)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	struct zfcp_dbf *dbf = adapter->dbf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	struct zfcp_dbf_rec *rec = &dbf->rec_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	static int const level = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 	struct list_head *entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 	lockdep_assert_held(&adapter->erp_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 	if (unlikely(!debug_level_enabled(dbf->rec, level)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	spin_lock_irqsave(&dbf->rec_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 	memset(rec, 0, sizeof(*rec));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 	rec->id = ZFCP_DBF_REC_TRIG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	zfcp_dbf_set_common(rec, adapter, port, sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	list_for_each(entry, &adapter->erp_ready_head)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 		rec->u.trig.ready++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 	list_for_each(entry, &adapter->erp_running_head)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 		rec->u.trig.running++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 	rec->u.trig.want = want;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 	rec->u.trig.need = need;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 	debug_event(dbf->rec, level, rec, sizeof(*rec));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	spin_unlock_irqrestore(&dbf->rec_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)  * zfcp_dbf_rec_trig_lock - trace event related to triggered recovery with lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357)  * @tag: identifier for event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358)  * @adapter: adapter on which the erp_action should run
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359)  * @port: remote port involved in the erp_action
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360)  * @sdev: scsi device involved in the erp_action
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361)  * @want: wanted erp_action
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)  * @need: required erp_action
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364)  * The adapter->erp_lock must not be held.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) void zfcp_dbf_rec_trig_lock(char *tag, struct zfcp_adapter *adapter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 			    struct zfcp_port *port, struct scsi_device *sdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 			    u8 want, u8 need)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 	read_lock_irqsave(&adapter->erp_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 	zfcp_dbf_rec_trig(tag, adapter, port, sdev, want, need);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 	read_unlock_irqrestore(&adapter->erp_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378)  * zfcp_dbf_rec_run_lvl - trace event related to running recovery
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379)  * @level: trace level to be used for event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380)  * @tag: identifier for event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381)  * @erp: erp_action running
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) void zfcp_dbf_rec_run_lvl(int level, char *tag, struct zfcp_erp_action *erp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 	struct zfcp_dbf *dbf = erp->adapter->dbf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 	struct zfcp_dbf_rec *rec = &dbf->rec_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 	if (!debug_level_enabled(dbf->rec, level))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 	spin_lock_irqsave(&dbf->rec_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 	memset(rec, 0, sizeof(*rec));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 	rec->id = ZFCP_DBF_REC_RUN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 	memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 	zfcp_dbf_set_common(rec, erp->adapter, erp->port, erp->sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 	rec->u.run.fsf_req_id = erp->fsf_req_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 	rec->u.run.rec_status = erp->status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 	rec->u.run.rec_step = erp->step;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 	rec->u.run.rec_action = erp->type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 	if (erp->sdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 		rec->u.run.rec_count =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 			atomic_read(&sdev_to_zfcp(erp->sdev)->erp_counter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 	else if (erp->port)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 		rec->u.run.rec_count = atomic_read(&erp->port->erp_counter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 		rec->u.run.rec_count = atomic_read(&erp->adapter->erp_counter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 	debug_event(dbf->rec, level, rec, sizeof(*rec));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 	spin_unlock_irqrestore(&dbf->rec_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417)  * zfcp_dbf_rec_run - trace event related to running recovery
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418)  * @tag: identifier for event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419)  * @erp: erp_action running
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) void zfcp_dbf_rec_run(char *tag, struct zfcp_erp_action *erp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 	zfcp_dbf_rec_run_lvl(1, tag, erp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427)  * zfcp_dbf_rec_run_wka - trace wka port event with info like running recovery
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428)  * @tag: identifier for event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429)  * @wka_port: well known address port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430)  * @req_id: request ID to correlate with potential HBA trace record
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) void zfcp_dbf_rec_run_wka(char *tag, struct zfcp_fc_wka_port *wka_port,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 			  u64 req_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 	struct zfcp_dbf *dbf = wka_port->adapter->dbf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 	struct zfcp_dbf_rec *rec = &dbf->rec_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 	static int const level = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 	if (unlikely(!debug_level_enabled(dbf->rec, level)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 	spin_lock_irqsave(&dbf->rec_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 	memset(rec, 0, sizeof(*rec));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 	rec->id = ZFCP_DBF_REC_RUN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 	memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 	rec->port_status = wka_port->status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 	rec->d_id = wka_port->d_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 	rec->lun = ZFCP_DBF_INVALID_LUN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 	rec->u.run.fsf_req_id = req_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 	rec->u.run.rec_status = ~0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 	rec->u.run.rec_step = ~0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 	rec->u.run.rec_action = ~0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 	rec->u.run.rec_count = ~0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 	debug_event(dbf->rec, level, rec, sizeof(*rec));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 	spin_unlock_irqrestore(&dbf->rec_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) #define ZFCP_DBF_SAN_LEVEL 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) static inline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) void zfcp_dbf_san(char *tag, struct zfcp_dbf *dbf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 		  char *paytag, struct scatterlist *sg, u8 id, u16 len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 		  u64 req_id, u32 d_id, u16 cap_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 	struct zfcp_dbf_san *rec = &dbf->san_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 	u16 rec_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 	struct zfcp_dbf_pay *payload = &dbf->pay_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 	u16 pay_sum = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 	spin_lock_irqsave(&dbf->san_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 	memset(rec, 0, sizeof(*rec));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 	rec->id = id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 	rec->fsf_req_id = req_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 	rec->d_id = d_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 	memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 	rec->pl_len = len; /* full length even if we cap pay below */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 	if (!sg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 	rec_len = min_t(unsigned int, sg->length, ZFCP_DBF_SAN_MAX_PAYLOAD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 	memcpy(rec->payload, sg_virt(sg), rec_len); /* part of 1st sg entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 	if (len <= rec_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 		goto out; /* skip pay record if full content in rec->payload */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 	/* if (len > rec_len):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 	 * dump data up to cap_len ignoring small duplicate in rec->payload
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 	spin_lock(&dbf->pay_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 	memset(payload, 0, sizeof(*payload));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 	memcpy(payload->area, paytag, ZFCP_DBF_TAG_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 	payload->fsf_req_id = req_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 	payload->counter = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 	for (; sg && pay_sum < cap_len; sg = sg_next(sg)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 		u16 pay_len, offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 		while (offset < sg->length && pay_sum < cap_len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 			pay_len = min((u16)ZFCP_DBF_PAY_MAX_REC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 				      (u16)(sg->length - offset));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 			/* cap_len <= pay_sum < cap_len+ZFCP_DBF_PAY_MAX_REC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 			memcpy(payload->data, sg_virt(sg) + offset, pay_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 			debug_event(dbf->pay, ZFCP_DBF_SAN_LEVEL, payload,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 				    zfcp_dbf_plen(pay_len));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 			payload->counter++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 			offset += pay_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 			pay_sum += pay_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 	spin_unlock(&dbf->pay_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) 	debug_event(dbf->san, ZFCP_DBF_SAN_LEVEL, rec, sizeof(*rec));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 	spin_unlock_irqrestore(&dbf->san_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521)  * zfcp_dbf_san_req - trace event for issued SAN request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522)  * @tag: identifier for event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523)  * @fsf: request containing issued CT or ELS data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524)  * @d_id: N_Port_ID where SAN request is sent to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525)  * d_id: destination ID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) void zfcp_dbf_san_req(char *tag, struct zfcp_fsf_req *fsf, u32 d_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 	struct zfcp_dbf *dbf = fsf->adapter->dbf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) 	struct zfcp_fsf_ct_els *ct_els = fsf->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) 	u16 length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) 	if (unlikely(!debug_level_enabled(dbf->san, ZFCP_DBF_SAN_LEVEL)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) 	length = (u16)zfcp_qdio_real_bytes(ct_els->req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) 	zfcp_dbf_san(tag, dbf, "san_req", ct_els->req, ZFCP_DBF_SAN_REQ,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) 		     length, fsf->req_id, d_id, length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) static u16 zfcp_dbf_san_res_cap_len_if_gpn_ft(char *tag,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) 					      struct zfcp_fsf_req *fsf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) 					      u16 len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) 	struct zfcp_fsf_ct_els *ct_els = fsf->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) 	struct fc_ct_hdr *reqh = sg_virt(ct_els->req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 	struct fc_ns_gid_ft *reqn = (struct fc_ns_gid_ft *)(reqh + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 	struct scatterlist *resp_entry = ct_els->resp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) 	struct fc_ct_hdr *resph;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 	struct fc_gpn_ft_resp *acc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) 	int max_entries, x, last = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) 	if (!(memcmp(tag, "fsscth2", 7) == 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) 	      && ct_els->d_id == FC_FID_DIR_SERV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) 	      && reqh->ct_rev == FC_CT_REV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 	      && reqh->ct_in_id[0] == 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) 	      && reqh->ct_in_id[1] == 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) 	      && reqh->ct_in_id[2] == 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) 	      && reqh->ct_fs_type == FC_FST_DIR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) 	      && reqh->ct_fs_subtype == FC_NS_SUBTYPE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) 	      && reqh->ct_options == 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) 	      && reqh->_ct_resvd1 == 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) 	      && reqh->ct_cmd == cpu_to_be16(FC_NS_GPN_FT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) 	      /* reqh->ct_mr_size can vary so do not match but read below */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) 	      && reqh->_ct_resvd2 == 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) 	      && reqh->ct_reason == 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) 	      && reqh->ct_explan == 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) 	      && reqh->ct_vendor == 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) 	      && reqn->fn_resvd == 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) 	      && reqn->fn_domain_id_scope == 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) 	      && reqn->fn_area_id_scope == 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) 	      && reqn->fn_fc4_type == FC_TYPE_FCP))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) 		return len; /* not GPN_FT response so do not cap */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) 	acc = sg_virt(resp_entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) 	/* cap all but accept CT responses to at least the CT header */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) 	resph = (struct fc_ct_hdr *)acc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) 	if ((ct_els->status) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) 	    (resph->ct_cmd != cpu_to_be16(FC_FS_ACC)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) 		return max(FC_CT_HDR_LEN, ZFCP_DBF_SAN_MAX_PAYLOAD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) 	max_entries = (be16_to_cpu(reqh->ct_mr_size) * 4 /
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) 		       sizeof(struct fc_gpn_ft_resp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) 		+ 1 /* zfcp_fc_scan_ports: bytes correct, entries off-by-one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) 		     * to account for header as 1st pseudo "entry" */;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) 	/* the basic CT_IU preamble is the same size as one entry in the GPN_FT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) 	 * response, allowing us to skip special handling for it - just skip it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) 	for (x = 1; x < max_entries && !last; x++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) 		if (x % (ZFCP_FC_GPN_FT_ENT_PAGE + 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) 			acc++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) 			acc = sg_virt(++resp_entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) 		last = acc->fp_flags & FC_NS_FID_LAST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) 	len = min(len, (u16)(x * sizeof(struct fc_gpn_ft_resp)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) 	return len; /* cap after last entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604)  * zfcp_dbf_san_res - trace event for received SAN request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605)  * @tag: identifier for event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606)  * @fsf: request containing received CT or ELS data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) void zfcp_dbf_san_res(char *tag, struct zfcp_fsf_req *fsf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) 	struct zfcp_dbf *dbf = fsf->adapter->dbf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) 	struct zfcp_fsf_ct_els *ct_els = fsf->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) 	u16 length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) 	if (unlikely(!debug_level_enabled(dbf->san, ZFCP_DBF_SAN_LEVEL)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) 	length = (u16)zfcp_qdio_real_bytes(ct_els->resp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) 	zfcp_dbf_san(tag, dbf, "san_res", ct_els->resp, ZFCP_DBF_SAN_RES,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) 		     length, fsf->req_id, ct_els->d_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) 		     zfcp_dbf_san_res_cap_len_if_gpn_ft(tag, fsf, length));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624)  * zfcp_dbf_san_in_els - trace event for incoming ELS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625)  * @tag: identifier for event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626)  * @fsf: request containing received ELS data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) void zfcp_dbf_san_in_els(char *tag, struct zfcp_fsf_req *fsf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) 	struct zfcp_dbf *dbf = fsf->adapter->dbf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) 	struct fsf_status_read_buffer *srb =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) 		(struct fsf_status_read_buffer *) fsf->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) 	u16 length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) 	struct scatterlist sg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) 	if (unlikely(!debug_level_enabled(dbf->san, ZFCP_DBF_SAN_LEVEL)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) 	length = (u16)(srb->length -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) 			offsetof(struct fsf_status_read_buffer, payload));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) 	sg_init_one(&sg, srb->payload.data, length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) 	zfcp_dbf_san(tag, dbf, "san_els", &sg, ZFCP_DBF_SAN_ELS, length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) 		     fsf->req_id, ntoh24(srb->d_id), length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647)  * zfcp_dbf_scsi_common() - Common trace event helper for scsi.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648)  * @tag: Identifier for event.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649)  * @level: trace level of event.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650)  * @sdev: Pointer to SCSI device as context for this event.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651)  * @sc: Pointer to SCSI command, or NULL with task management function (TMF).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652)  * @fsf: Pointer to FSF request, or NULL.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) void zfcp_dbf_scsi_common(char *tag, int level, struct scsi_device *sdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) 			  struct scsi_cmnd *sc, struct zfcp_fsf_req *fsf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) 	struct zfcp_adapter *adapter =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) 		(struct zfcp_adapter *) sdev->host->hostdata[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) 	struct zfcp_dbf *dbf = adapter->dbf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) 	struct zfcp_dbf_scsi *rec = &dbf->scsi_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) 	struct fcp_resp_with_ext *fcp_rsp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) 	struct fcp_resp_rsp_info *fcp_rsp_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) 	spin_lock_irqsave(&dbf->scsi_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) 	memset(rec, 0, sizeof(*rec));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) 	memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) 	rec->id = ZFCP_DBF_SCSI_CMND;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) 	if (sc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) 		rec->scsi_result = sc->result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) 		rec->scsi_retries = sc->retries;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) 		rec->scsi_allowed = sc->allowed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) 		rec->scsi_id = sc->device->id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) 		rec->scsi_lun = (u32)sc->device->lun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) 		rec->scsi_lun_64_hi = (u32)(sc->device->lun >> 32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) 		rec->host_scribble = (unsigned long)sc->host_scribble;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) 		memcpy(rec->scsi_opcode, sc->cmnd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) 		       min_t(int, sc->cmd_len, ZFCP_DBF_SCSI_OPCODE));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) 		rec->scsi_result = ~0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) 		rec->scsi_retries = ~0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) 		rec->scsi_allowed = ~0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) 		rec->scsi_id = sdev->id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) 		rec->scsi_lun = (u32)sdev->lun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) 		rec->scsi_lun_64_hi = (u32)(sdev->lun >> 32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) 		rec->host_scribble = ~0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) 		memset(rec->scsi_opcode, 0xff, ZFCP_DBF_SCSI_OPCODE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) 	if (fsf) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) 		rec->fsf_req_id = fsf->req_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) 		rec->pl_len = FCP_RESP_WITH_EXT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) 		fcp_rsp = &(fsf->qtcb->bottom.io.fcp_rsp.iu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) 		/* mandatory parts of FCP_RSP IU in this SCSI record */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) 		memcpy(&rec->fcp_rsp, fcp_rsp, FCP_RESP_WITH_EXT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) 		if (fcp_rsp->resp.fr_flags & FCP_RSP_LEN_VAL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) 			fcp_rsp_info = (struct fcp_resp_rsp_info *) &fcp_rsp[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) 			rec->fcp_rsp_info = fcp_rsp_info->rsp_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) 			rec->pl_len += be32_to_cpu(fcp_rsp->ext.fr_rsp_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) 		if (fcp_rsp->resp.fr_flags & FCP_SNS_LEN_VAL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) 			rec->pl_len += be32_to_cpu(fcp_rsp->ext.fr_sns_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) 		/* complete FCP_RSP IU in associated PAYload record
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) 		 * but only if there are optional parts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) 		if (fcp_rsp->resp.fr_flags != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) 			zfcp_dbf_pl_write(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) 				dbf, fcp_rsp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) 				/* at least one full PAY record
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) 				 * but not beyond hardware response field
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) 				 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) 				min_t(u16, max_t(u16, rec->pl_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) 						 ZFCP_DBF_PAY_MAX_REC),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) 				      FSF_FCP_RSP_SIZE),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) 				"fcp_riu", fsf->req_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) 	debug_event(dbf->scsi, level, rec, sizeof(*rec));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) 	spin_unlock_irqrestore(&dbf->scsi_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727)  * zfcp_dbf_scsi_eh() - Trace event for special cases of scsi_eh callbacks.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728)  * @tag: Identifier for event.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729)  * @adapter: Pointer to zfcp adapter as context for this event.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730)  * @scsi_id: SCSI ID/target to indicate scope of task management function (TMF).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731)  * @ret: Return value of calling function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733)  * This SCSI trace variant does not depend on any of:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734)  * scsi_cmnd, zfcp_fsf_req, scsi_device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) void zfcp_dbf_scsi_eh(char *tag, struct zfcp_adapter *adapter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) 		      unsigned int scsi_id, int ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) 	struct zfcp_dbf *dbf = adapter->dbf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) 	struct zfcp_dbf_scsi *rec = &dbf->scsi_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) 	static int const level = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) 	if (unlikely(!debug_level_enabled(adapter->dbf->scsi, level)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) 	spin_lock_irqsave(&dbf->scsi_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) 	memset(rec, 0, sizeof(*rec));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) 	memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) 	rec->id = ZFCP_DBF_SCSI_CMND;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) 	rec->scsi_result = ret; /* re-use field, int is 4 bytes and fits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) 	rec->scsi_retries = ~0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) 	rec->scsi_allowed = ~0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) 	rec->fcp_rsp_info = ~0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) 	rec->scsi_id = scsi_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) 	rec->scsi_lun = (u32)ZFCP_DBF_INVALID_LUN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) 	rec->scsi_lun_64_hi = (u32)(ZFCP_DBF_INVALID_LUN >> 32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) 	rec->host_scribble = ~0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) 	memset(rec->scsi_opcode, 0xff, ZFCP_DBF_SCSI_OPCODE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) 	debug_event(dbf->scsi, level, rec, sizeof(*rec));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) 	spin_unlock_irqrestore(&dbf->scsi_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) static debug_info_t *zfcp_dbf_reg(const char *name, int size, int rec_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) 	struct debug_info *d;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) 	d = debug_register(name, size, 1, rec_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) 	if (!d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) 	debug_register_view(d, &debug_hex_ascii_view);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) 	debug_set_level(d, dbflevel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) 	return d;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) static void zfcp_dbf_unregister(struct zfcp_dbf *dbf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) 	if (!dbf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) 	debug_unregister(dbf->scsi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) 	debug_unregister(dbf->san);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) 	debug_unregister(dbf->hba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) 	debug_unregister(dbf->pay);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) 	debug_unregister(dbf->rec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) 	kfree(dbf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794)  * zfcp_adapter_debug_register - registers debug feature for an adapter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795)  * @adapter: pointer to adapter for which debug features should be registered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796)  * return: -ENOMEM on error, 0 otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) int zfcp_dbf_adapter_register(struct zfcp_adapter *adapter)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) 	char name[DEBUG_MAX_NAME_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) 	struct zfcp_dbf *dbf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) 	dbf = kzalloc(sizeof(struct zfcp_dbf), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) 	if (!dbf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) 	spin_lock_init(&dbf->pay_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) 	spin_lock_init(&dbf->hba_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) 	spin_lock_init(&dbf->san_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) 	spin_lock_init(&dbf->scsi_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) 	spin_lock_init(&dbf->rec_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) 	/* debug feature area which records recovery activity */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) 	sprintf(name, "zfcp_%s_rec", dev_name(&adapter->ccw_device->dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) 	dbf->rec = zfcp_dbf_reg(name, dbfsize, sizeof(struct zfcp_dbf_rec));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) 	if (!dbf->rec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) 		goto err_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) 	/* debug feature area which records HBA (FSF and QDIO) conditions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) 	sprintf(name, "zfcp_%s_hba", dev_name(&adapter->ccw_device->dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) 	dbf->hba = zfcp_dbf_reg(name, dbfsize, sizeof(struct zfcp_dbf_hba));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) 	if (!dbf->hba)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) 		goto err_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) 	/* debug feature area which records payload info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) 	sprintf(name, "zfcp_%s_pay", dev_name(&adapter->ccw_device->dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) 	dbf->pay = zfcp_dbf_reg(name, dbfsize * 2, sizeof(struct zfcp_dbf_pay));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) 	if (!dbf->pay)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) 		goto err_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) 	/* debug feature area which records SAN command failures and recovery */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) 	sprintf(name, "zfcp_%s_san", dev_name(&adapter->ccw_device->dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) 	dbf->san = zfcp_dbf_reg(name, dbfsize, sizeof(struct zfcp_dbf_san));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) 	if (!dbf->san)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) 		goto err_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) 	/* debug feature area which records SCSI command failures and recovery */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) 	sprintf(name, "zfcp_%s_scsi", dev_name(&adapter->ccw_device->dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) 	dbf->scsi = zfcp_dbf_reg(name, dbfsize, sizeof(struct zfcp_dbf_scsi));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) 	if (!dbf->scsi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) 		goto err_out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) 	adapter->dbf = dbf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) err_out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) 	zfcp_dbf_unregister(dbf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) 	return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852)  * zfcp_adapter_debug_unregister - unregisters debug feature for an adapter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853)  * @adapter: pointer to adapter for which debug features should be unregistered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) void zfcp_dbf_adapter_unregister(struct zfcp_adapter *adapter)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) 	struct zfcp_dbf *dbf = adapter->dbf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) 	adapter->dbf = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) 	zfcp_dbf_unregister(dbf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862)