| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 1 | /* | 
| Christof Schmitt | 553448f | 2008-06-10 18:20:58 +0200 | [diff] [blame] | 2 |  * zfcp device driver | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 3 |  * | 
| Christof Schmitt | 553448f | 2008-06-10 18:20:58 +0200 | [diff] [blame] | 4 |  * Debug traces for zfcp. | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 5 |  * | 
| Heiko Carstens | a53c8fa | 2012-07-20 11:15:04 +0200 | [diff] [blame] | 6 |  * Copyright IBM Corp. 2002, 2010 | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 7 |  */ | 
 | 8 |  | 
| Christof Schmitt | ecf39d4 | 2008-12-25 13:39:53 +0100 | [diff] [blame] | 9 | #define KMSG_COMPONENT "zfcp" | 
 | 10 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt | 
 | 11 |  | 
| Heiko Carstens | 3a4c5d5 | 2011-07-30 09:25:15 +0200 | [diff] [blame] | 12 | #include <linux/module.h> | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 13 | #include <linux/ctype.h> | 
| Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 14 | #include <linux/slab.h> | 
| Heiko Carstens | 364c855 | 2007-10-12 16:11:35 +0200 | [diff] [blame] | 15 | #include <asm/debug.h> | 
| Christof Schmitt | d46f384 | 2009-08-18 15:43:07 +0200 | [diff] [blame] | 16 | #include "zfcp_dbf.h" | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 17 | #include "zfcp_ext.h" | 
| Christof Schmitt | bd0072e | 2009-11-24 16:54:11 +0100 | [diff] [blame] | 18 | #include "zfcp_fc.h" | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 19 |  | 
 | 20 | static u32 dbfsize = 4; | 
 | 21 |  | 
 | 22 | module_param(dbfsize, uint, 0400); | 
 | 23 | MODULE_PARM_DESC(dbfsize, | 
 | 24 | 		 "number of pages for each debug feature area (default 4)"); | 
 | 25 |  | 
| Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 26 | static inline unsigned int zfcp_dbf_plen(unsigned int offset) | 
| Martin Peschke | c15450e | 2008-03-27 14:21:55 +0100 | [diff] [blame] | 27 | { | 
| Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 28 | 	return sizeof(struct zfcp_dbf_pay) + offset - ZFCP_DBF_PAY_MAX_REC; | 
 | 29 | } | 
| Martin Peschke | c15450e | 2008-03-27 14:21:55 +0100 | [diff] [blame] | 30 |  | 
| Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 31 | static inline | 
 | 32 | void zfcp_dbf_pl_write(struct zfcp_dbf *dbf, void *data, u16 length, char *area, | 
 | 33 | 		       u64 req_id) | 
 | 34 | { | 
 | 35 | 	struct zfcp_dbf_pay *pl = &dbf->pay_buf; | 
 | 36 | 	u16 offset = 0, rec_length; | 
 | 37 |  | 
 | 38 | 	spin_lock(&dbf->pay_lock); | 
 | 39 | 	memset(pl, 0, sizeof(*pl)); | 
 | 40 | 	pl->fsf_req_id = req_id; | 
 | 41 | 	memcpy(pl->area, area, ZFCP_DBF_TAG_LEN); | 
 | 42 |  | 
 | 43 | 	while (offset < length) { | 
 | 44 | 		rec_length = min((u16) ZFCP_DBF_PAY_MAX_REC, | 
 | 45 | 				 (u16) (length - offset)); | 
 | 46 | 		memcpy(pl->data, data + offset, rec_length); | 
 | 47 | 		debug_event(dbf->pay, 1, pl, zfcp_dbf_plen(rec_length)); | 
 | 48 |  | 
 | 49 | 		offset += rec_length; | 
 | 50 | 		pl->counter++; | 
| Martin Peschke | c15450e | 2008-03-27 14:21:55 +0100 | [diff] [blame] | 51 | 	} | 
| Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 52 |  | 
 | 53 | 	spin_unlock(&dbf->pay_lock); | 
| Martin Peschke | c15450e | 2008-03-27 14:21:55 +0100 | [diff] [blame] | 54 | } | 
 | 55 |  | 
| Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 56 | /** | 
 | 57 |  * zfcp_dbf_hba_fsf_res - trace event for fsf responses | 
 | 58 |  * @tag: tag indicating which kind of unsolicited status has been received | 
 | 59 |  * @req: request for which a response was received | 
 | 60 |  */ | 
 | 61 | void zfcp_dbf_hba_fsf_res(char *tag, struct zfcp_fsf_req *req) | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 62 | { | 
| Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 63 | 	struct zfcp_dbf *dbf = req->adapter->dbf; | 
 | 64 | 	struct fsf_qtcb_prefix *q_pref = &req->qtcb->prefix; | 
 | 65 | 	struct fsf_qtcb_header *q_head = &req->qtcb->header; | 
 | 66 | 	struct zfcp_dbf_hba *rec = &dbf->hba_buf; | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 67 | 	unsigned long flags; | 
 | 68 |  | 
| Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 69 | 	spin_lock_irqsave(&dbf->hba_lock, flags); | 
| Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 70 | 	memset(rec, 0, sizeof(*rec)); | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 71 |  | 
| Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 72 | 	memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN); | 
 | 73 | 	rec->id = ZFCP_DBF_HBA_RES; | 
 | 74 | 	rec->fsf_req_id = req->req_id; | 
 | 75 | 	rec->fsf_req_status = req->status; | 
 | 76 | 	rec->fsf_cmd = req->fsf_command; | 
 | 77 | 	rec->fsf_seq_no = req->seq_no; | 
 | 78 | 	rec->u.res.req_issued = req->issued; | 
 | 79 | 	rec->u.res.prot_status = q_pref->prot_status; | 
 | 80 | 	rec->u.res.fsf_status = q_head->fsf_status; | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 81 |  | 
| Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 82 | 	memcpy(rec->u.res.prot_status_qual, &q_pref->prot_status_qual, | 
 | 83 | 	       FSF_PROT_STATUS_QUAL_SIZE); | 
 | 84 | 	memcpy(rec->u.res.fsf_status_qual, &q_head->fsf_status_qual, | 
 | 85 | 	       FSF_STATUS_QUALIFIER_SIZE); | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 86 |  | 
| Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 87 | 	if (req->fsf_command != FSF_QTCB_FCP_CMND) { | 
 | 88 | 		rec->pl_len = q_head->log_length; | 
 | 89 | 		zfcp_dbf_pl_write(dbf, (char *)q_pref + q_head->log_start, | 
 | 90 | 				  rec->pl_len, "fsf_res", req->req_id); | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 91 | 	} | 
 | 92 |  | 
| Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 93 | 	debug_event(dbf->hba, 1, rec, sizeof(*rec)); | 
| Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 94 | 	spin_unlock_irqrestore(&dbf->hba_lock, flags); | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 95 | } | 
 | 96 |  | 
| Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 97 | /** | 
 | 98 |  * zfcp_dbf_hba_fsf_uss - trace event for an unsolicited status buffer | 
 | 99 |  * @tag: tag indicating which kind of unsolicited status has been received | 
 | 100 |  * @req: request providing the unsolicited status | 
 | 101 |  */ | 
 | 102 | void zfcp_dbf_hba_fsf_uss(char *tag, struct zfcp_fsf_req *req) | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 103 | { | 
| Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 104 | 	struct zfcp_dbf *dbf = req->adapter->dbf; | 
 | 105 | 	struct fsf_status_read_buffer *srb = req->data; | 
 | 106 | 	struct zfcp_dbf_hba *rec = &dbf->hba_buf; | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 107 | 	unsigned long flags; | 
 | 108 |  | 
| Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 109 | 	spin_lock_irqsave(&dbf->hba_lock, flags); | 
| Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 110 | 	memset(rec, 0, sizeof(*rec)); | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 111 |  | 
| Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 112 | 	memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN); | 
 | 113 | 	rec->id = ZFCP_DBF_HBA_USS; | 
 | 114 | 	rec->fsf_req_id = req->req_id; | 
 | 115 | 	rec->fsf_req_status = req->status; | 
 | 116 | 	rec->fsf_cmd = req->fsf_command; | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 117 |  | 
| Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 118 | 	if (!srb) | 
 | 119 | 		goto log; | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 120 |  | 
| Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 121 | 	rec->u.uss.status_type = srb->status_type; | 
 | 122 | 	rec->u.uss.status_subtype = srb->status_subtype; | 
 | 123 | 	rec->u.uss.d_id = ntoh24(srb->d_id); | 
 | 124 | 	rec->u.uss.lun = srb->fcp_lun; | 
 | 125 | 	memcpy(&rec->u.uss.queue_designator, &srb->queue_designator, | 
 | 126 | 	       sizeof(rec->u.uss.queue_designator)); | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 127 |  | 
| Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 128 | 	/* status read buffer payload length */ | 
 | 129 | 	rec->pl_len = (!srb->length) ? 0 : srb->length - | 
 | 130 | 			offsetof(struct fsf_status_read_buffer, payload); | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 131 |  | 
| Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 132 | 	if (rec->pl_len) | 
 | 133 | 		zfcp_dbf_pl_write(dbf, srb->payload.data, rec->pl_len, | 
 | 134 | 				  "fsf_uss", req->req_id); | 
 | 135 | log: | 
 | 136 | 	debug_event(dbf->hba, 2, rec, sizeof(*rec)); | 
| Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 137 | 	spin_unlock_irqrestore(&dbf->hba_lock, flags); | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 138 | } | 
 | 139 |  | 
| Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 140 | /** | 
| Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 141 |  * zfcp_dbf_hba_bit_err - trace event for bit error conditions | 
 | 142 |  * @tag: tag indicating which kind of unsolicited status has been received | 
 | 143 |  * @req: request which caused the bit_error condition | 
| Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 144 |  */ | 
| Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 145 | void zfcp_dbf_hba_bit_err(char *tag, struct zfcp_fsf_req *req) | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 146 | { | 
| Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 147 | 	struct zfcp_dbf *dbf = req->adapter->dbf; | 
 | 148 | 	struct zfcp_dbf_hba *rec = &dbf->hba_buf; | 
| Swen Schillig | 5706938 | 2008-10-01 12:42:21 +0200 | [diff] [blame] | 149 | 	struct fsf_status_read_buffer *sr_buf = req->data; | 
| Swen Schillig | 5706938 | 2008-10-01 12:42:21 +0200 | [diff] [blame] | 150 | 	unsigned long flags; | 
 | 151 |  | 
| Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 152 | 	spin_lock_irqsave(&dbf->hba_lock, flags); | 
| Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 153 | 	memset(rec, 0, sizeof(*rec)); | 
 | 154 |  | 
 | 155 | 	memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN); | 
 | 156 | 	rec->id = ZFCP_DBF_HBA_BIT; | 
 | 157 | 	rec->fsf_req_id = req->req_id; | 
 | 158 | 	rec->fsf_req_status = req->status; | 
 | 159 | 	rec->fsf_cmd = req->fsf_command; | 
 | 160 | 	memcpy(&rec->u.be, &sr_buf->payload.bit_error, | 
 | 161 | 	       sizeof(struct fsf_bit_error_payload)); | 
 | 162 |  | 
 | 163 | 	debug_event(dbf->hba, 1, rec, sizeof(*rec)); | 
| Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 164 | 	spin_unlock_irqrestore(&dbf->hba_lock, flags); | 
| Swen Schillig | 5706938 | 2008-10-01 12:42:21 +0200 | [diff] [blame] | 165 | } | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 166 |  | 
| Swen Schillig | 86a9668 | 2011-08-15 14:40:32 +0200 | [diff] [blame] | 167 | /** | 
 | 168 |  * zfcp_dbf_hba_def_err - trace event for deferred error messages | 
 | 169 |  * @adapter: pointer to struct zfcp_adapter | 
 | 170 |  * @req_id: request id which caused the deferred error message | 
 | 171 |  * @scount: number of sbals incl. the signaling sbal | 
 | 172 |  * @pl: array of all involved sbals | 
 | 173 |  */ | 
 | 174 | void zfcp_dbf_hba_def_err(struct zfcp_adapter *adapter, u64 req_id, u16 scount, | 
 | 175 | 			  void **pl) | 
 | 176 | { | 
 | 177 | 	struct zfcp_dbf *dbf = adapter->dbf; | 
 | 178 | 	struct zfcp_dbf_pay *payload = &dbf->pay_buf; | 
 | 179 | 	unsigned long flags; | 
 | 180 | 	u16 length; | 
 | 181 |  | 
 | 182 | 	if (!pl) | 
 | 183 | 		return; | 
 | 184 |  | 
 | 185 | 	spin_lock_irqsave(&dbf->pay_lock, flags); | 
 | 186 | 	memset(payload, 0, sizeof(*payload)); | 
 | 187 |  | 
 | 188 | 	memcpy(payload->area, "def_err", 7); | 
 | 189 | 	payload->fsf_req_id = req_id; | 
 | 190 | 	payload->counter = 0; | 
 | 191 | 	length = min((u16)sizeof(struct qdio_buffer), | 
 | 192 | 		     (u16)ZFCP_DBF_PAY_MAX_REC); | 
 | 193 |  | 
| Steffen Maier | 01e6052 | 2012-09-04 15:23:31 +0200 | [diff] [blame] | 194 | 	while (payload->counter < scount && (char *)pl[payload->counter]) { | 
| Swen Schillig | 86a9668 | 2011-08-15 14:40:32 +0200 | [diff] [blame] | 195 | 		memcpy(payload->data, (char *)pl[payload->counter], length); | 
 | 196 | 		debug_event(dbf->pay, 1, payload, zfcp_dbf_plen(length)); | 
 | 197 | 		payload->counter++; | 
 | 198 | 	} | 
 | 199 |  | 
 | 200 | 	spin_unlock_irqrestore(&dbf->pay_lock, flags); | 
 | 201 | } | 
 | 202 |  | 
| Steffen Maier | cb45214 | 2012-09-04 15:23:32 +0200 | [diff] [blame] | 203 | /** | 
 | 204 |  * zfcp_dbf_hba_basic - trace event for basic adapter events | 
 | 205 |  * @adapter: pointer to struct zfcp_adapter | 
 | 206 |  */ | 
 | 207 | void zfcp_dbf_hba_basic(char *tag, struct zfcp_adapter *adapter) | 
 | 208 | { | 
 | 209 | 	struct zfcp_dbf *dbf = adapter->dbf; | 
 | 210 | 	struct zfcp_dbf_hba *rec = &dbf->hba_buf; | 
 | 211 | 	unsigned long flags; | 
 | 212 |  | 
 | 213 | 	spin_lock_irqsave(&dbf->hba_lock, flags); | 
 | 214 | 	memset(rec, 0, sizeof(*rec)); | 
 | 215 |  | 
 | 216 | 	memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN); | 
 | 217 | 	rec->id = ZFCP_DBF_HBA_BASIC; | 
 | 218 |  | 
 | 219 | 	debug_event(dbf->hba, 1, rec, sizeof(*rec)); | 
 | 220 | 	spin_unlock_irqrestore(&dbf->hba_lock, flags); | 
 | 221 | } | 
 | 222 |  | 
| Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 223 | static void zfcp_dbf_set_common(struct zfcp_dbf_rec *rec, | 
 | 224 | 				struct zfcp_adapter *adapter, | 
 | 225 | 				struct zfcp_port *port, | 
 | 226 | 				struct scsi_device *sdev) | 
| Martin Peschke | d79a83d | 2008-03-27 14:22:00 +0100 | [diff] [blame] | 227 | { | 
| Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 228 | 	rec->adapter_status = atomic_read(&adapter->status); | 
 | 229 | 	if (port) { | 
 | 230 | 		rec->port_status = atomic_read(&port->status); | 
 | 231 | 		rec->wwpn = port->wwpn; | 
 | 232 | 		rec->d_id = port->d_id; | 
| Martin Peschke | d79a83d | 2008-03-27 14:22:00 +0100 | [diff] [blame] | 233 | 	} | 
| Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 234 | 	if (sdev) { | 
 | 235 | 		rec->lun_status = atomic_read(&sdev_to_zfcp(sdev)->status); | 
 | 236 | 		rec->lun = zfcp_scsi_dev_lun(sdev); | 
 | 237 | 	} | 
| Martin Peschke | 348447e | 2008-03-27 14:22:01 +0100 | [diff] [blame] | 238 | } | 
 | 239 |  | 
| Christof Schmitt | aa0fec6 | 2008-05-19 12:17:47 +0200 | [diff] [blame] | 240 | /** | 
| Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 241 |  * zfcp_dbf_rec_trig - trace event related to triggered recovery | 
 | 242 |  * @tag: identifier for event | 
 | 243 |  * @adapter: adapter on which the erp_action should run | 
 | 244 |  * @port: remote port involved in the erp_action | 
 | 245 |  * @sdev: scsi device involved in the erp_action | 
 | 246 |  * @want: wanted erp_action | 
 | 247 |  * @need: required erp_action | 
 | 248 |  * | 
 | 249 |  * The adapter->erp_lock has to be held. | 
| Christof Schmitt | aa0fec6 | 2008-05-19 12:17:47 +0200 | [diff] [blame] | 250 |  */ | 
| Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 251 | void zfcp_dbf_rec_trig(char *tag, struct zfcp_adapter *adapter, | 
 | 252 | 		       struct zfcp_port *port, struct scsi_device *sdev, | 
 | 253 | 		       u8 want, u8 need) | 
| Martin Peschke | 9467a9b | 2008-03-27 14:22:03 +0100 | [diff] [blame] | 254 | { | 
| Christof Schmitt | d46f384 | 2009-08-18 15:43:07 +0200 | [diff] [blame] | 255 | 	struct zfcp_dbf *dbf = adapter->dbf; | 
| Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 256 | 	struct zfcp_dbf_rec *rec = &dbf->rec_buf; | 
 | 257 | 	struct list_head *entry; | 
| Martin Peschke | 9467a9b | 2008-03-27 14:22:03 +0100 | [diff] [blame] | 258 | 	unsigned long flags; | 
 | 259 |  | 
| Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 260 | 	spin_lock_irqsave(&dbf->rec_lock, flags); | 
| Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 261 | 	memset(rec, 0, sizeof(*rec)); | 
 | 262 |  | 
 | 263 | 	rec->id = ZFCP_DBF_REC_TRIG; | 
 | 264 | 	memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN); | 
 | 265 | 	zfcp_dbf_set_common(rec, adapter, port, sdev); | 
 | 266 |  | 
 | 267 | 	list_for_each(entry, &adapter->erp_ready_head) | 
 | 268 | 		rec->u.trig.ready++; | 
 | 269 |  | 
 | 270 | 	list_for_each(entry, &adapter->erp_running_head) | 
 | 271 | 		rec->u.trig.running++; | 
 | 272 |  | 
 | 273 | 	rec->u.trig.want = want; | 
 | 274 | 	rec->u.trig.need = need; | 
 | 275 |  | 
 | 276 | 	debug_event(dbf->rec, 1, rec, sizeof(*rec)); | 
| Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 277 | 	spin_unlock_irqrestore(&dbf->rec_lock, flags); | 
| Martin Peschke | 9467a9b | 2008-03-27 14:22:03 +0100 | [diff] [blame] | 278 | } | 
 | 279 |  | 
| Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 280 |  | 
| Martin Peschke | 6f4f365 | 2008-03-27 14:22:04 +0100 | [diff] [blame] | 281 | /** | 
| Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 282 |  * zfcp_dbf_rec_run - trace event related to running recovery | 
 | 283 |  * @tag: identifier for event | 
 | 284 |  * @erp: erp_action running | 
| Martin Peschke | 6f4f365 | 2008-03-27 14:22:04 +0100 | [diff] [blame] | 285 |  */ | 
| Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 286 | void zfcp_dbf_rec_run(char *tag, struct zfcp_erp_action *erp) | 
| Martin Peschke | 6f4f365 | 2008-03-27 14:22:04 +0100 | [diff] [blame] | 287 | { | 
| Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 288 | 	struct zfcp_dbf *dbf = erp->adapter->dbf; | 
 | 289 | 	struct zfcp_dbf_rec *rec = &dbf->rec_buf; | 
| Martin Peschke | 6f4f365 | 2008-03-27 14:22:04 +0100 | [diff] [blame] | 290 | 	unsigned long flags; | 
 | 291 |  | 
| Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 292 | 	spin_lock_irqsave(&dbf->rec_lock, flags); | 
| Swen Schillig | ae0904f | 2010-12-02 15:16:12 +0100 | [diff] [blame] | 293 | 	memset(rec, 0, sizeof(*rec)); | 
 | 294 |  | 
 | 295 | 	rec->id = ZFCP_DBF_REC_RUN; | 
 | 296 | 	memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN); | 
 | 297 | 	zfcp_dbf_set_common(rec, erp->adapter, erp->port, erp->sdev); | 
 | 298 |  | 
 | 299 | 	rec->u.run.fsf_req_id = erp->fsf_req_id; | 
 | 300 | 	rec->u.run.rec_status = erp->status; | 
 | 301 | 	rec->u.run.rec_step = erp->step; | 
 | 302 | 	rec->u.run.rec_action = erp->action; | 
 | 303 |  | 
 | 304 | 	if (erp->sdev) | 
 | 305 | 		rec->u.run.rec_count = | 
 | 306 | 			atomic_read(&sdev_to_zfcp(erp->sdev)->erp_counter); | 
 | 307 | 	else if (erp->port) | 
 | 308 | 		rec->u.run.rec_count = atomic_read(&erp->port->erp_counter); | 
 | 309 | 	else | 
 | 310 | 		rec->u.run.rec_count = atomic_read(&erp->adapter->erp_counter); | 
 | 311 |  | 
 | 312 | 	debug_event(dbf->rec, 1, rec, sizeof(*rec)); | 
| Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 313 | 	spin_unlock_irqrestore(&dbf->rec_lock, flags); | 
| Martin Peschke | 6f4f365 | 2008-03-27 14:22:04 +0100 | [diff] [blame] | 314 | } | 
 | 315 |  | 
| Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame] | 316 | static inline | 
 | 317 | void zfcp_dbf_san(char *tag, struct zfcp_dbf *dbf, void *data, u8 id, u16 len, | 
 | 318 | 		  u64 req_id, u32 d_id) | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 319 | { | 
| Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame] | 320 | 	struct zfcp_dbf_san *rec = &dbf->san_buf; | 
 | 321 | 	u16 rec_len; | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 322 | 	unsigned long flags; | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 323 |  | 
| Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 324 | 	spin_lock_irqsave(&dbf->san_lock, flags); | 
| Martin Peschke | 6bc473d | 2008-03-31 11:15:29 +0200 | [diff] [blame] | 325 | 	memset(rec, 0, sizeof(*rec)); | 
| Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame] | 326 |  | 
 | 327 | 	rec->id = id; | 
 | 328 | 	rec->fsf_req_id = req_id; | 
 | 329 | 	rec->d_id = d_id; | 
 | 330 | 	rec_len = min(len, (u16)ZFCP_DBF_SAN_MAX_PAYLOAD); | 
 | 331 | 	memcpy(rec->payload, data, rec_len); | 
 | 332 | 	memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN); | 
 | 333 |  | 
 | 334 | 	debug_event(dbf->san, 1, rec, sizeof(*rec)); | 
| Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 335 | 	spin_unlock_irqrestore(&dbf->san_lock, flags); | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 336 | } | 
 | 337 |  | 
| Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 338 | /** | 
| Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame] | 339 |  * zfcp_dbf_san_req - trace event for issued SAN request | 
 | 340 |  * @tag: indentifier for event | 
 | 341 |  * @fsf_req: request containing issued CT data | 
 | 342 |  * d_id: destination ID | 
| Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 343 |  */ | 
| Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame] | 344 | void zfcp_dbf_san_req(char *tag, struct zfcp_fsf_req *fsf, u32 d_id) | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 345 | { | 
| Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame] | 346 | 	struct zfcp_dbf *dbf = fsf->adapter->dbf; | 
 | 347 | 	struct zfcp_fsf_ct_els *ct_els = fsf->data; | 
 | 348 | 	u16 length; | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 349 |  | 
| Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame] | 350 | 	length = (u16)(ct_els->req->length + FC_CT_HDR_LEN); | 
 | 351 | 	zfcp_dbf_san(tag, dbf, sg_virt(ct_els->req), ZFCP_DBF_SAN_REQ, length, | 
 | 352 | 		     fsf->req_id, d_id); | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 353 | } | 
 | 354 |  | 
| Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 355 | /** | 
| Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame] | 356 |  * zfcp_dbf_san_res - trace event for received SAN request | 
 | 357 |  * @tag: indentifier for event | 
 | 358 |  * @fsf_req: request containing issued CT data | 
| Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 359 |  */ | 
| Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame] | 360 | void zfcp_dbf_san_res(char *tag, struct zfcp_fsf_req *fsf) | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 361 | { | 
| Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame] | 362 | 	struct zfcp_dbf *dbf = fsf->adapter->dbf; | 
 | 363 | 	struct zfcp_fsf_ct_els *ct_els = fsf->data; | 
 | 364 | 	u16 length; | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 365 |  | 
| Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame] | 366 | 	length = (u16)(ct_els->resp->length + FC_CT_HDR_LEN); | 
 | 367 | 	zfcp_dbf_san(tag, dbf, sg_virt(ct_els->resp), ZFCP_DBF_SAN_RES, length, | 
 | 368 | 		     fsf->req_id, 0); | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 369 | } | 
 | 370 |  | 
| Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 371 | /** | 
| Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame] | 372 |  * zfcp_dbf_san_in_els - trace event for incoming ELS | 
 | 373 |  * @tag: indentifier for event | 
 | 374 |  * @fsf_req: request containing issued CT data | 
| Martin Peschke | bfab163 | 2008-03-31 11:15:31 +0200 | [diff] [blame] | 375 |  */ | 
| Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame] | 376 | void zfcp_dbf_san_in_els(char *tag, struct zfcp_fsf_req *fsf) | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 377 | { | 
| Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame] | 378 | 	struct zfcp_dbf *dbf = fsf->adapter->dbf; | 
 | 379 | 	struct fsf_status_read_buffer *srb = | 
 | 380 | 		(struct fsf_status_read_buffer *) fsf->data; | 
 | 381 | 	u16 length; | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 382 |  | 
| Swen Schillig | 2c55b75 | 2010-12-02 15:16:13 +0100 | [diff] [blame] | 383 | 	length = (u16)(srb->length - | 
 | 384 | 			offsetof(struct fsf_status_read_buffer, payload)); | 
 | 385 | 	zfcp_dbf_san(tag, dbf, srb->payload.data, ZFCP_DBF_SAN_ELS, length, | 
 | 386 | 		     fsf->req_id, ntoh24(srb->d_id)); | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 387 | } | 
 | 388 |  | 
| Swen Schillig | 250a135 | 2010-12-02 15:16:15 +0100 | [diff] [blame] | 389 | /** | 
 | 390 |  * zfcp_dbf_scsi - trace event for scsi commands | 
 | 391 |  * @tag: identifier for event | 
 | 392 |  * @sc: pointer to struct scsi_cmnd | 
 | 393 |  * @fsf: pointer to struct zfcp_fsf_req | 
 | 394 |  */ | 
 | 395 | void zfcp_dbf_scsi(char *tag, struct scsi_cmnd *sc, struct zfcp_fsf_req *fsf) | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 396 | { | 
| Swen Schillig | 250a135 | 2010-12-02 15:16:15 +0100 | [diff] [blame] | 397 | 	struct zfcp_adapter *adapter = | 
 | 398 | 		(struct zfcp_adapter *) sc->device->host->hostdata[0]; | 
 | 399 | 	struct zfcp_dbf *dbf = adapter->dbf; | 
 | 400 | 	struct zfcp_dbf_scsi *rec = &dbf->scsi_buf; | 
| Christof Schmitt | 4318e08 | 2009-11-24 16:54:08 +0100 | [diff] [blame] | 401 | 	struct fcp_resp_with_ext *fcp_rsp; | 
| Swen Schillig | 250a135 | 2010-12-02 15:16:15 +0100 | [diff] [blame] | 402 | 	struct fcp_resp_rsp_info *fcp_rsp_info; | 
 | 403 | 	unsigned long flags; | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 404 |  | 
| Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 405 | 	spin_lock_irqsave(&dbf->scsi_lock, flags); | 
| Swen Schillig | 250a135 | 2010-12-02 15:16:15 +0100 | [diff] [blame] | 406 | 	memset(rec, 0, sizeof(*rec)); | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 407 |  | 
| Swen Schillig | 250a135 | 2010-12-02 15:16:15 +0100 | [diff] [blame] | 408 | 	memcpy(rec->tag, tag, ZFCP_DBF_TAG_LEN); | 
 | 409 | 	rec->id = ZFCP_DBF_SCSI_CMND; | 
 | 410 | 	rec->scsi_result = sc->result; | 
 | 411 | 	rec->scsi_retries = sc->retries; | 
 | 412 | 	rec->scsi_allowed = sc->allowed; | 
 | 413 | 	rec->scsi_id = sc->device->id; | 
 | 414 | 	rec->scsi_lun = sc->device->lun; | 
 | 415 | 	rec->host_scribble = (unsigned long)sc->host_scribble; | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 416 |  | 
| Swen Schillig | 250a135 | 2010-12-02 15:16:15 +0100 | [diff] [blame] | 417 | 	memcpy(rec->scsi_opcode, sc->cmnd, | 
 | 418 | 	       min((int)sc->cmd_len, ZFCP_DBF_SCSI_OPCODE)); | 
 | 419 |  | 
 | 420 | 	if (fsf) { | 
 | 421 | 		rec->fsf_req_id = fsf->req_id; | 
 | 422 | 		fcp_rsp = (struct fcp_resp_with_ext *) | 
 | 423 | 				&(fsf->qtcb->bottom.io.fcp_rsp); | 
 | 424 | 		memcpy(&rec->fcp_rsp, fcp_rsp, FCP_RESP_WITH_EXT); | 
 | 425 | 		if (fcp_rsp->resp.fr_flags & FCP_RSP_LEN_VAL) { | 
 | 426 | 			fcp_rsp_info = (struct fcp_resp_rsp_info *) &fcp_rsp[1]; | 
 | 427 | 			rec->fcp_rsp_info = fcp_rsp_info->rsp_code; | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 428 | 		} | 
| Swen Schillig | 250a135 | 2010-12-02 15:16:15 +0100 | [diff] [blame] | 429 | 		if (fcp_rsp->resp.fr_flags & FCP_SNS_LEN_VAL) { | 
 | 430 | 			rec->pl_len = min((u16)SCSI_SENSE_BUFFERSIZE, | 
 | 431 | 					  (u16)ZFCP_DBF_PAY_MAX_REC); | 
 | 432 | 			zfcp_dbf_pl_write(dbf, sc->sense_buffer, rec->pl_len, | 
 | 433 | 					  "fcp_sns", fsf->req_id); | 
 | 434 | 		} | 
 | 435 | 	} | 
 | 436 |  | 
| Swen Schillig | ea4a3a6 | 2010-12-02 15:16:16 +0100 | [diff] [blame] | 437 | 	debug_event(dbf->scsi, 1, rec, sizeof(*rec)); | 
| Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 438 | 	spin_unlock_irqrestore(&dbf->scsi_lock, flags); | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 439 | } | 
 | 440 |  | 
| Swen Schillig | ea4a3a6 | 2010-12-02 15:16:16 +0100 | [diff] [blame] | 441 | static debug_info_t *zfcp_dbf_reg(const char *name, int size, int rec_size) | 
| Christof Schmitt | d46f384 | 2009-08-18 15:43:07 +0200 | [diff] [blame] | 442 | { | 
 | 443 | 	struct debug_info *d; | 
 | 444 |  | 
| Swen Schillig | ea4a3a6 | 2010-12-02 15:16:16 +0100 | [diff] [blame] | 445 | 	d = debug_register(name, size, 1, rec_size); | 
| Christof Schmitt | d46f384 | 2009-08-18 15:43:07 +0200 | [diff] [blame] | 446 | 	if (!d) | 
 | 447 | 		return NULL; | 
 | 448 |  | 
 | 449 | 	debug_register_view(d, &debug_hex_ascii_view); | 
| Swen Schillig | ea4a3a6 | 2010-12-02 15:16:16 +0100 | [diff] [blame] | 450 | 	debug_set_level(d, 3); | 
| Christof Schmitt | d46f384 | 2009-08-18 15:43:07 +0200 | [diff] [blame] | 451 |  | 
 | 452 | 	return d; | 
 | 453 | } | 
 | 454 |  | 
| Swen Schillig | ea4a3a6 | 2010-12-02 15:16:16 +0100 | [diff] [blame] | 455 | static void zfcp_dbf_unregister(struct zfcp_dbf *dbf) | 
 | 456 | { | 
 | 457 | 	if (!dbf) | 
 | 458 | 		return; | 
 | 459 |  | 
 | 460 | 	debug_unregister(dbf->scsi); | 
 | 461 | 	debug_unregister(dbf->san); | 
 | 462 | 	debug_unregister(dbf->hba); | 
 | 463 | 	debug_unregister(dbf->pay); | 
 | 464 | 	debug_unregister(dbf->rec); | 
 | 465 | 	kfree(dbf); | 
 | 466 | } | 
 | 467 |  | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 468 | /** | 
 | 469 |  * zfcp_adapter_debug_register - registers debug feature for an adapter | 
 | 470 |  * @adapter: pointer to adapter for which debug features should be registered | 
 | 471 |  * return: -ENOMEM on error, 0 otherwise | 
 | 472 |  */ | 
| Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 473 | int zfcp_dbf_adapter_register(struct zfcp_adapter *adapter) | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 474 | { | 
| Swen Schillig | ea4a3a6 | 2010-12-02 15:16:16 +0100 | [diff] [blame] | 475 | 	char name[DEBUG_MAX_NAME_LEN]; | 
| Christof Schmitt | d46f384 | 2009-08-18 15:43:07 +0200 | [diff] [blame] | 476 | 	struct zfcp_dbf *dbf; | 
 | 477 |  | 
| Swen Schillig | d23948e | 2010-07-16 15:37:40 +0200 | [diff] [blame] | 478 | 	dbf = kzalloc(sizeof(struct zfcp_dbf), GFP_KERNEL); | 
| Christof Schmitt | d46f384 | 2009-08-18 15:43:07 +0200 | [diff] [blame] | 479 | 	if (!dbf) | 
 | 480 | 		return -ENOMEM; | 
 | 481 |  | 
| Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 482 | 	spin_lock_init(&dbf->pay_lock); | 
| Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 483 | 	spin_lock_init(&dbf->hba_lock); | 
 | 484 | 	spin_lock_init(&dbf->san_lock); | 
 | 485 | 	spin_lock_init(&dbf->scsi_lock); | 
 | 486 | 	spin_lock_init(&dbf->rec_lock); | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 487 |  | 
 | 488 | 	/* debug feature area which records recovery activity */ | 
| Swen Schillig | ea4a3a6 | 2010-12-02 15:16:16 +0100 | [diff] [blame] | 489 | 	sprintf(name, "zfcp_%s_rec", dev_name(&adapter->ccw_device->dev)); | 
 | 490 | 	dbf->rec = zfcp_dbf_reg(name, dbfsize, sizeof(struct zfcp_dbf_rec)); | 
| Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 491 | 	if (!dbf->rec) | 
 | 492 | 		goto err_out; | 
| Martin Peschke | d79a83d | 2008-03-27 14:22:00 +0100 | [diff] [blame] | 493 |  | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 494 | 	/* debug feature area which records HBA (FSF and QDIO) conditions */ | 
| Swen Schillig | ea4a3a6 | 2010-12-02 15:16:16 +0100 | [diff] [blame] | 495 | 	sprintf(name, "zfcp_%s_hba", dev_name(&adapter->ccw_device->dev)); | 
 | 496 | 	dbf->hba = zfcp_dbf_reg(name, dbfsize, sizeof(struct zfcp_dbf_hba)); | 
| Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 497 | 	if (!dbf->hba) | 
 | 498 | 		goto err_out; | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 499 |  | 
| Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 500 | 	/* debug feature area which records payload info */ | 
| Swen Schillig | ea4a3a6 | 2010-12-02 15:16:16 +0100 | [diff] [blame] | 501 | 	sprintf(name, "zfcp_%s_pay", dev_name(&adapter->ccw_device->dev)); | 
 | 502 | 	dbf->pay = zfcp_dbf_reg(name, dbfsize * 2, sizeof(struct zfcp_dbf_pay)); | 
| Swen Schillig | a54ca0f | 2010-12-02 15:16:14 +0100 | [diff] [blame] | 503 | 	if (!dbf->pay) | 
 | 504 | 		goto err_out; | 
 | 505 |  | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 506 | 	/* debug feature area which records SAN command failures and recovery */ | 
| Swen Schillig | ea4a3a6 | 2010-12-02 15:16:16 +0100 | [diff] [blame] | 507 | 	sprintf(name, "zfcp_%s_san", dev_name(&adapter->ccw_device->dev)); | 
 | 508 | 	dbf->san = zfcp_dbf_reg(name, dbfsize, sizeof(struct zfcp_dbf_san)); | 
| Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 509 | 	if (!dbf->san) | 
 | 510 | 		goto err_out; | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 511 |  | 
 | 512 | 	/* debug feature area which records SCSI command failures and recovery */ | 
| Swen Schillig | ea4a3a6 | 2010-12-02 15:16:16 +0100 | [diff] [blame] | 513 | 	sprintf(name, "zfcp_%s_scsi", dev_name(&adapter->ccw_device->dev)); | 
 | 514 | 	dbf->scsi = zfcp_dbf_reg(name, dbfsize, sizeof(struct zfcp_dbf_scsi)); | 
| Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 515 | 	if (!dbf->scsi) | 
 | 516 | 		goto err_out; | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 517 |  | 
| Christof Schmitt | d46f384 | 2009-08-18 15:43:07 +0200 | [diff] [blame] | 518 | 	adapter->dbf = dbf; | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 519 |  | 
| Swen Schillig | ea4a3a6 | 2010-12-02 15:16:16 +0100 | [diff] [blame] | 520 | 	return 0; | 
| Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 521 | err_out: | 
| Swen Schillig | ea4a3a6 | 2010-12-02 15:16:16 +0100 | [diff] [blame] | 522 | 	zfcp_dbf_unregister(dbf); | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 523 | 	return -ENOMEM; | 
 | 524 | } | 
 | 525 |  | 
 | 526 | /** | 
 | 527 |  * zfcp_adapter_debug_unregister - unregisters debug feature for an adapter | 
| Swen Schillig | ea4a3a6 | 2010-12-02 15:16:16 +0100 | [diff] [blame] | 528 |  * @adapter: pointer to adapter for which debug features should be unregistered | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 529 |  */ | 
| Swen Schillig | ea4a3a6 | 2010-12-02 15:16:16 +0100 | [diff] [blame] | 530 | void zfcp_dbf_adapter_unregister(struct zfcp_adapter *adapter) | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 531 | { | 
| Swen Schillig | ea4a3a6 | 2010-12-02 15:16:16 +0100 | [diff] [blame] | 532 | 	struct zfcp_dbf *dbf = adapter->dbf; | 
 | 533 |  | 
 | 534 | 	adapter->dbf = NULL; | 
 | 535 | 	zfcp_dbf_unregister(dbf); | 
| Maxim Shchetynin | 8a36e45 | 2005-09-13 21:50:38 +0200 | [diff] [blame] | 536 | } | 
| Swen Schillig | 5771710 | 2009-08-18 15:43:21 +0200 | [diff] [blame] | 537 |  |