zfcp_dbf.c 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033
  1. /*
  2. * This file is part of the zfcp device driver for
  3. * FCP adapters for IBM System z9 and zSeries.
  4. *
  5. * (C) Copyright IBM Corp. 2002, 2006
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2, or (at your option)
  10. * any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */
  21. #include <linux/ctype.h>
  22. #include <asm/debug.h>
  23. #include "zfcp_ext.h"
  24. static u32 dbfsize = 4;
  25. module_param(dbfsize, uint, 0400);
  26. MODULE_PARM_DESC(dbfsize,
  27. "number of pages for each debug feature area (default 4)");
  28. #define ZFCP_LOG_AREA ZFCP_LOG_AREA_OTHER
  29. static void zfcp_dbf_hexdump(debug_info_t *dbf, void *to, int to_len,
  30. int level, char *from, int from_len)
  31. {
  32. int offset;
  33. struct zfcp_dbf_dump *dump = to;
  34. int room = to_len - sizeof(*dump);
  35. for (offset = 0; offset < from_len; offset += dump->size) {
  36. memset(to, 0, to_len);
  37. strncpy(dump->tag, "dump", ZFCP_DBF_TAG_SIZE);
  38. dump->total_size = from_len;
  39. dump->offset = offset;
  40. dump->size = min(from_len - offset, room);
  41. memcpy(dump->data, from + offset, dump->size);
  42. debug_event(dbf, level, dump, dump->size);
  43. }
  44. }
  45. static int
  46. zfcp_dbf_stck(char *out_buf, const char *label, unsigned long long stck)
  47. {
  48. unsigned long long sec;
  49. struct timespec dbftime;
  50. int len = 0;
  51. stck -= 0x8126d60e46000000LL - (0x3c26700LL * 1000000 * 4096);
  52. sec = stck >> 12;
  53. do_div(sec, 1000000);
  54. dbftime.tv_sec = sec;
  55. stck -= (sec * 1000000) << 12;
  56. dbftime.tv_nsec = ((stck * 1000) >> 12);
  57. len += sprintf(out_buf + len, "%-24s%011lu:%06lu\n",
  58. label, dbftime.tv_sec, dbftime.tv_nsec);
  59. return len;
  60. }
  61. static int zfcp_dbf_tag(char *out_buf, const char *label, const char *tag)
  62. {
  63. int len = 0, i;
  64. len += sprintf(out_buf + len, "%-24s", label);
  65. for (i = 0; i < ZFCP_DBF_TAG_SIZE; i++)
  66. len += sprintf(out_buf + len, "%c", tag[i]);
  67. len += sprintf(out_buf + len, "\n");
  68. return len;
  69. }
  70. static int
  71. zfcp_dbf_view(char *out_buf, const char *label, const char *format, ...)
  72. {
  73. va_list arg;
  74. int len = 0;
  75. len += sprintf(out_buf + len, "%-24s", label);
  76. va_start(arg, format);
  77. len += vsprintf(out_buf + len, format, arg);
  78. va_end(arg);
  79. len += sprintf(out_buf + len, "\n");
  80. return len;
  81. }
  82. static void zfcp_dbf_outs(char **buf, const char *s1, const char *s2)
  83. {
  84. *buf += sprintf(*buf, "%-24s%s\n", s1, s2);
  85. }
  86. static void zfcp_dbf_out(char **buf, const char *s, const char *format, ...)
  87. {
  88. va_list arg;
  89. *buf += sprintf(*buf, "%-24s", s);
  90. va_start(arg, format);
  91. *buf += vsprintf(*buf, format, arg);
  92. va_end(arg);
  93. *buf += sprintf(*buf, "\n");
  94. }
  95. static int
  96. zfcp_dbf_view_dump(char *out_buf, const char *label,
  97. char *buffer, int buflen, int offset, int total_size)
  98. {
  99. int len = 0;
  100. if (offset == 0)
  101. len += sprintf(out_buf + len, "%-24s ", label);
  102. while (buflen--) {
  103. if (offset > 0) {
  104. if ((offset % 32) == 0)
  105. len += sprintf(out_buf + len, "\n%-24c ", ' ');
  106. else if ((offset % 4) == 0)
  107. len += sprintf(out_buf + len, " ");
  108. }
  109. len += sprintf(out_buf + len, "%02x", *buffer++);
  110. if (++offset == total_size) {
  111. len += sprintf(out_buf + len, "\n");
  112. break;
  113. }
  114. }
  115. if (total_size == 0)
  116. len += sprintf(out_buf + len, "\n");
  117. return len;
  118. }
  119. static int
  120. zfcp_dbf_view_header(debug_info_t * id, struct debug_view *view, int area,
  121. debug_entry_t * entry, char *out_buf)
  122. {
  123. struct zfcp_dbf_dump *dump = (struct zfcp_dbf_dump *)DEBUG_DATA(entry);
  124. int len = 0;
  125. if (strncmp(dump->tag, "dump", ZFCP_DBF_TAG_SIZE) != 0) {
  126. len += zfcp_dbf_stck(out_buf + len, "timestamp",
  127. entry->id.stck);
  128. len += zfcp_dbf_view(out_buf + len, "cpu", "%02i",
  129. entry->id.fields.cpuid);
  130. } else {
  131. len += zfcp_dbf_view_dump(out_buf + len, NULL,
  132. dump->data,
  133. dump->size,
  134. dump->offset, dump->total_size);
  135. if ((dump->offset + dump->size) == dump->total_size)
  136. len += sprintf(out_buf + len, "\n");
  137. }
  138. return len;
  139. }
  140. void zfcp_hba_dbf_event_fsf_response(struct zfcp_fsf_req *fsf_req)
  141. {
  142. struct zfcp_adapter *adapter = fsf_req->adapter;
  143. struct fsf_qtcb *qtcb = fsf_req->qtcb;
  144. union fsf_prot_status_qual *prot_status_qual =
  145. &qtcb->prefix.prot_status_qual;
  146. union fsf_status_qual *fsf_status_qual = &qtcb->header.fsf_status_qual;
  147. struct scsi_cmnd *scsi_cmnd;
  148. struct zfcp_port *port;
  149. struct zfcp_unit *unit;
  150. struct zfcp_send_els *send_els;
  151. struct zfcp_hba_dbf_record *rec = &adapter->hba_dbf_buf;
  152. struct zfcp_hba_dbf_record_response *response = &rec->type.response;
  153. int level;
  154. unsigned long flags;
  155. spin_lock_irqsave(&adapter->hba_dbf_lock, flags);
  156. memset(rec, 0, sizeof(struct zfcp_hba_dbf_record));
  157. strncpy(rec->tag, "resp", ZFCP_DBF_TAG_SIZE);
  158. if ((qtcb->prefix.prot_status != FSF_PROT_GOOD) &&
  159. (qtcb->prefix.prot_status != FSF_PROT_FSF_STATUS_PRESENTED)) {
  160. strncpy(rec->tag2, "perr", ZFCP_DBF_TAG_SIZE);
  161. level = 1;
  162. } else if (qtcb->header.fsf_status != FSF_GOOD) {
  163. strncpy(rec->tag2, "ferr", ZFCP_DBF_TAG_SIZE);
  164. level = 1;
  165. } else if ((fsf_req->fsf_command == FSF_QTCB_OPEN_PORT_WITH_DID) ||
  166. (fsf_req->fsf_command == FSF_QTCB_OPEN_LUN)) {
  167. strncpy(rec->tag2, "open", ZFCP_DBF_TAG_SIZE);
  168. level = 4;
  169. } else if (qtcb->header.log_length) {
  170. strncpy(rec->tag2, "qtcb", ZFCP_DBF_TAG_SIZE);
  171. level = 5;
  172. } else {
  173. strncpy(rec->tag2, "norm", ZFCP_DBF_TAG_SIZE);
  174. level = 6;
  175. }
  176. response->fsf_command = fsf_req->fsf_command;
  177. response->fsf_reqid = (unsigned long)fsf_req;
  178. response->fsf_seqno = fsf_req->seq_no;
  179. response->fsf_issued = fsf_req->issued;
  180. response->fsf_prot_status = qtcb->prefix.prot_status;
  181. response->fsf_status = qtcb->header.fsf_status;
  182. memcpy(response->fsf_prot_status_qual,
  183. prot_status_qual, FSF_PROT_STATUS_QUAL_SIZE);
  184. memcpy(response->fsf_status_qual,
  185. fsf_status_qual, FSF_STATUS_QUALIFIER_SIZE);
  186. response->fsf_req_status = fsf_req->status;
  187. response->sbal_first = fsf_req->sbal_first;
  188. response->sbal_curr = fsf_req->sbal_curr;
  189. response->sbal_last = fsf_req->sbal_last;
  190. response->pool = fsf_req->pool != NULL;
  191. response->erp_action = (unsigned long)fsf_req->erp_action;
  192. switch (fsf_req->fsf_command) {
  193. case FSF_QTCB_FCP_CMND:
  194. if (fsf_req->status & ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT)
  195. break;
  196. scsi_cmnd = (struct scsi_cmnd *)fsf_req->data;
  197. if (scsi_cmnd != NULL) {
  198. response->data.send_fcp.scsi_cmnd
  199. = (unsigned long)scsi_cmnd;
  200. response->data.send_fcp.scsi_serial
  201. = scsi_cmnd->serial_number;
  202. }
  203. break;
  204. case FSF_QTCB_OPEN_PORT_WITH_DID:
  205. case FSF_QTCB_CLOSE_PORT:
  206. case FSF_QTCB_CLOSE_PHYSICAL_PORT:
  207. port = (struct zfcp_port *)fsf_req->data;
  208. response->data.port.wwpn = port->wwpn;
  209. response->data.port.d_id = port->d_id;
  210. response->data.port.port_handle = qtcb->header.port_handle;
  211. break;
  212. case FSF_QTCB_OPEN_LUN:
  213. case FSF_QTCB_CLOSE_LUN:
  214. unit = (struct zfcp_unit *)fsf_req->data;
  215. port = unit->port;
  216. response->data.unit.wwpn = port->wwpn;
  217. response->data.unit.fcp_lun = unit->fcp_lun;
  218. response->data.unit.port_handle = qtcb->header.port_handle;
  219. response->data.unit.lun_handle = qtcb->header.lun_handle;
  220. break;
  221. case FSF_QTCB_SEND_ELS:
  222. send_els = (struct zfcp_send_els *)fsf_req->data;
  223. response->data.send_els.d_id = qtcb->bottom.support.d_id;
  224. response->data.send_els.ls_code = send_els->ls_code >> 24;
  225. break;
  226. case FSF_QTCB_ABORT_FCP_CMND:
  227. case FSF_QTCB_SEND_GENERIC:
  228. case FSF_QTCB_EXCHANGE_CONFIG_DATA:
  229. case FSF_QTCB_EXCHANGE_PORT_DATA:
  230. case FSF_QTCB_DOWNLOAD_CONTROL_FILE:
  231. case FSF_QTCB_UPLOAD_CONTROL_FILE:
  232. break;
  233. }
  234. debug_event(adapter->hba_dbf, level,
  235. rec, sizeof(struct zfcp_hba_dbf_record));
  236. /* have fcp channel microcode fixed to use as little as possible */
  237. if (fsf_req->fsf_command != FSF_QTCB_FCP_CMND) {
  238. /* adjust length skipping trailing zeros */
  239. char *buf = (char *)qtcb + qtcb->header.log_start;
  240. int len = qtcb->header.log_length;
  241. for (; len && !buf[len - 1]; len--);
  242. zfcp_dbf_hexdump(adapter->hba_dbf, rec, sizeof(*rec), level,
  243. buf, len);
  244. }
  245. spin_unlock_irqrestore(&adapter->hba_dbf_lock, flags);
  246. }
  247. void
  248. zfcp_hba_dbf_event_fsf_unsol(const char *tag, struct zfcp_adapter *adapter,
  249. struct fsf_status_read_buffer *status_buffer)
  250. {
  251. struct zfcp_hba_dbf_record *rec = &adapter->hba_dbf_buf;
  252. unsigned long flags;
  253. spin_lock_irqsave(&adapter->hba_dbf_lock, flags);
  254. memset(rec, 0, sizeof(struct zfcp_hba_dbf_record));
  255. strncpy(rec->tag, "stat", ZFCP_DBF_TAG_SIZE);
  256. strncpy(rec->tag2, tag, ZFCP_DBF_TAG_SIZE);
  257. rec->type.status.failed = adapter->status_read_failed;
  258. if (status_buffer != NULL) {
  259. rec->type.status.status_type = status_buffer->status_type;
  260. rec->type.status.status_subtype = status_buffer->status_subtype;
  261. memcpy(&rec->type.status.queue_designator,
  262. &status_buffer->queue_designator,
  263. sizeof(struct fsf_queue_designator));
  264. switch (status_buffer->status_type) {
  265. case FSF_STATUS_READ_SENSE_DATA_AVAIL:
  266. rec->type.status.payload_size =
  267. ZFCP_DBF_UNSOL_PAYLOAD_SENSE_DATA_AVAIL;
  268. break;
  269. case FSF_STATUS_READ_BIT_ERROR_THRESHOLD:
  270. rec->type.status.payload_size =
  271. ZFCP_DBF_UNSOL_PAYLOAD_BIT_ERROR_THRESHOLD;
  272. break;
  273. case FSF_STATUS_READ_LINK_DOWN:
  274. switch (status_buffer->status_subtype) {
  275. case FSF_STATUS_READ_SUB_NO_PHYSICAL_LINK:
  276. case FSF_STATUS_READ_SUB_FDISC_FAILED:
  277. rec->type.status.payload_size =
  278. sizeof(struct fsf_link_down_info);
  279. }
  280. break;
  281. case FSF_STATUS_READ_FEATURE_UPDATE_ALERT:
  282. rec->type.status.payload_size =
  283. ZFCP_DBF_UNSOL_PAYLOAD_FEATURE_UPDATE_ALERT;
  284. break;
  285. }
  286. memcpy(&rec->type.status.payload,
  287. &status_buffer->payload, rec->type.status.payload_size);
  288. }
  289. debug_event(adapter->hba_dbf, 2,
  290. rec, sizeof(struct zfcp_hba_dbf_record));
  291. spin_unlock_irqrestore(&adapter->hba_dbf_lock, flags);
  292. }
  293. void
  294. zfcp_hba_dbf_event_qdio(struct zfcp_adapter *adapter, unsigned int status,
  295. unsigned int qdio_error, unsigned int siga_error,
  296. int sbal_index, int sbal_count)
  297. {
  298. struct zfcp_hba_dbf_record *rec = &adapter->hba_dbf_buf;
  299. unsigned long flags;
  300. spin_lock_irqsave(&adapter->hba_dbf_lock, flags);
  301. memset(rec, 0, sizeof(struct zfcp_hba_dbf_record));
  302. strncpy(rec->tag, "qdio", ZFCP_DBF_TAG_SIZE);
  303. rec->type.qdio.status = status;
  304. rec->type.qdio.qdio_error = qdio_error;
  305. rec->type.qdio.siga_error = siga_error;
  306. rec->type.qdio.sbal_index = sbal_index;
  307. rec->type.qdio.sbal_count = sbal_count;
  308. debug_event(adapter->hba_dbf, 0,
  309. rec, sizeof(struct zfcp_hba_dbf_record));
  310. spin_unlock_irqrestore(&adapter->hba_dbf_lock, flags);
  311. }
  312. static int
  313. zfcp_hba_dbf_view_response(char *out_buf,
  314. struct zfcp_hba_dbf_record_response *rec)
  315. {
  316. int len = 0;
  317. len += zfcp_dbf_view(out_buf + len, "fsf_command", "0x%08x",
  318. rec->fsf_command);
  319. len += zfcp_dbf_view(out_buf + len, "fsf_reqid", "0x%0Lx",
  320. rec->fsf_reqid);
  321. len += zfcp_dbf_view(out_buf + len, "fsf_seqno", "0x%08x",
  322. rec->fsf_seqno);
  323. len += zfcp_dbf_stck(out_buf + len, "fsf_issued", rec->fsf_issued);
  324. len += zfcp_dbf_view(out_buf + len, "fsf_prot_status", "0x%08x",
  325. rec->fsf_prot_status);
  326. len += zfcp_dbf_view(out_buf + len, "fsf_status", "0x%08x",
  327. rec->fsf_status);
  328. len += zfcp_dbf_view_dump(out_buf + len, "fsf_prot_status_qual",
  329. rec->fsf_prot_status_qual,
  330. FSF_PROT_STATUS_QUAL_SIZE,
  331. 0, FSF_PROT_STATUS_QUAL_SIZE);
  332. len += zfcp_dbf_view_dump(out_buf + len, "fsf_status_qual",
  333. rec->fsf_status_qual,
  334. FSF_STATUS_QUALIFIER_SIZE,
  335. 0, FSF_STATUS_QUALIFIER_SIZE);
  336. len += zfcp_dbf_view(out_buf + len, "fsf_req_status", "0x%08x",
  337. rec->fsf_req_status);
  338. len += zfcp_dbf_view(out_buf + len, "sbal_first", "0x%02x",
  339. rec->sbal_first);
  340. len += zfcp_dbf_view(out_buf + len, "sbal_curr", "0x%02x",
  341. rec->sbal_curr);
  342. len += zfcp_dbf_view(out_buf + len, "sbal_last", "0x%02x",
  343. rec->sbal_last);
  344. len += zfcp_dbf_view(out_buf + len, "pool", "0x%02x", rec->pool);
  345. switch (rec->fsf_command) {
  346. case FSF_QTCB_FCP_CMND:
  347. if (rec->fsf_req_status & ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT)
  348. break;
  349. len += zfcp_dbf_view(out_buf + len, "scsi_cmnd", "0x%0Lx",
  350. rec->data.send_fcp.scsi_cmnd);
  351. len += zfcp_dbf_view(out_buf + len, "scsi_serial", "0x%016Lx",
  352. rec->data.send_fcp.scsi_serial);
  353. break;
  354. case FSF_QTCB_OPEN_PORT_WITH_DID:
  355. case FSF_QTCB_CLOSE_PORT:
  356. case FSF_QTCB_CLOSE_PHYSICAL_PORT:
  357. len += zfcp_dbf_view(out_buf + len, "wwpn", "0x%016Lx",
  358. rec->data.port.wwpn);
  359. len += zfcp_dbf_view(out_buf + len, "d_id", "0x%06x",
  360. rec->data.port.d_id);
  361. len += zfcp_dbf_view(out_buf + len, "port_handle", "0x%08x",
  362. rec->data.port.port_handle);
  363. break;
  364. case FSF_QTCB_OPEN_LUN:
  365. case FSF_QTCB_CLOSE_LUN:
  366. len += zfcp_dbf_view(out_buf + len, "wwpn", "0x%016Lx",
  367. rec->data.unit.wwpn);
  368. len += zfcp_dbf_view(out_buf + len, "fcp_lun", "0x%016Lx",
  369. rec->data.unit.fcp_lun);
  370. len += zfcp_dbf_view(out_buf + len, "port_handle", "0x%08x",
  371. rec->data.unit.port_handle);
  372. len += zfcp_dbf_view(out_buf + len, "lun_handle", "0x%08x",
  373. rec->data.unit.lun_handle);
  374. break;
  375. case FSF_QTCB_SEND_ELS:
  376. len += zfcp_dbf_view(out_buf + len, "d_id", "0x%06x",
  377. rec->data.send_els.d_id);
  378. len += zfcp_dbf_view(out_buf + len, "ls_code", "0x%02x",
  379. rec->data.send_els.ls_code);
  380. break;
  381. case FSF_QTCB_ABORT_FCP_CMND:
  382. case FSF_QTCB_SEND_GENERIC:
  383. case FSF_QTCB_EXCHANGE_CONFIG_DATA:
  384. case FSF_QTCB_EXCHANGE_PORT_DATA:
  385. case FSF_QTCB_DOWNLOAD_CONTROL_FILE:
  386. case FSF_QTCB_UPLOAD_CONTROL_FILE:
  387. break;
  388. }
  389. return len;
  390. }
  391. static int
  392. zfcp_hba_dbf_view_status(char *out_buf, struct zfcp_hba_dbf_record_status *rec)
  393. {
  394. int len = 0;
  395. len += zfcp_dbf_view(out_buf + len, "failed", "0x%02x", rec->failed);
  396. len += zfcp_dbf_view(out_buf + len, "status_type", "0x%08x",
  397. rec->status_type);
  398. len += zfcp_dbf_view(out_buf + len, "status_subtype", "0x%08x",
  399. rec->status_subtype);
  400. len += zfcp_dbf_view_dump(out_buf + len, "queue_designator",
  401. (char *)&rec->queue_designator,
  402. sizeof(struct fsf_queue_designator),
  403. 0, sizeof(struct fsf_queue_designator));
  404. len += zfcp_dbf_view_dump(out_buf + len, "payload",
  405. (char *)&rec->payload,
  406. rec->payload_size, 0, rec->payload_size);
  407. return len;
  408. }
  409. static int
  410. zfcp_hba_dbf_view_qdio(char *out_buf, struct zfcp_hba_dbf_record_qdio *rec)
  411. {
  412. int len = 0;
  413. len += zfcp_dbf_view(out_buf + len, "status", "0x%08x", rec->status);
  414. len += zfcp_dbf_view(out_buf + len, "qdio_error", "0x%08x",
  415. rec->qdio_error);
  416. len += zfcp_dbf_view(out_buf + len, "siga_error", "0x%08x",
  417. rec->siga_error);
  418. len += zfcp_dbf_view(out_buf + len, "sbal_index", "0x%02x",
  419. rec->sbal_index);
  420. len += zfcp_dbf_view(out_buf + len, "sbal_count", "0x%02x",
  421. rec->sbal_count);
  422. return len;
  423. }
  424. static int
  425. zfcp_hba_dbf_view_format(debug_info_t * id, struct debug_view *view,
  426. char *out_buf, const char *in_buf)
  427. {
  428. struct zfcp_hba_dbf_record *rec = (struct zfcp_hba_dbf_record *)in_buf;
  429. int len = 0;
  430. if (strncmp(rec->tag, "dump", ZFCP_DBF_TAG_SIZE) == 0)
  431. return 0;
  432. len += zfcp_dbf_tag(out_buf + len, "tag", rec->tag);
  433. if (isalpha(rec->tag2[0]))
  434. len += zfcp_dbf_tag(out_buf + len, "tag2", rec->tag2);
  435. if (strncmp(rec->tag, "resp", ZFCP_DBF_TAG_SIZE) == 0)
  436. len += zfcp_hba_dbf_view_response(out_buf + len,
  437. &rec->type.response);
  438. else if (strncmp(rec->tag, "stat", ZFCP_DBF_TAG_SIZE) == 0)
  439. len += zfcp_hba_dbf_view_status(out_buf + len,
  440. &rec->type.status);
  441. else if (strncmp(rec->tag, "qdio", ZFCP_DBF_TAG_SIZE) == 0)
  442. len += zfcp_hba_dbf_view_qdio(out_buf + len, &rec->type.qdio);
  443. len += sprintf(out_buf + len, "\n");
  444. return len;
  445. }
  446. static struct debug_view zfcp_hba_dbf_view = {
  447. "structured",
  448. NULL,
  449. &zfcp_dbf_view_header,
  450. &zfcp_hba_dbf_view_format,
  451. NULL,
  452. NULL
  453. };
  454. static const char *zfcp_rec_dbf_tags[] = {
  455. };
  456. static const char *zfcp_rec_dbf_ids[] = {
  457. };
  458. static int zfcp_rec_dbf_view_format(debug_info_t *id, struct debug_view *view,
  459. char *buf, const char *_rec)
  460. {
  461. struct zfcp_rec_dbf_record *r = (struct zfcp_rec_dbf_record *)_rec;
  462. char *p = buf;
  463. zfcp_dbf_outs(&p, "tag", zfcp_rec_dbf_tags[r->id]);
  464. zfcp_dbf_outs(&p, "hint", zfcp_rec_dbf_ids[r->id2]);
  465. zfcp_dbf_out(&p, "id", "%d", r->id2);
  466. switch (r->id) {
  467. }
  468. sprintf(p, "\n");
  469. return (p - buf) + 1;
  470. }
  471. static struct debug_view zfcp_rec_dbf_view = {
  472. "structured",
  473. NULL,
  474. &zfcp_dbf_view_header,
  475. &zfcp_rec_dbf_view_format,
  476. NULL,
  477. NULL
  478. };
  479. static void
  480. _zfcp_san_dbf_event_common_ct(const char *tag, struct zfcp_fsf_req *fsf_req,
  481. u32 s_id, u32 d_id, void *buffer, int buflen)
  482. {
  483. struct zfcp_send_ct *send_ct = (struct zfcp_send_ct *)fsf_req->data;
  484. struct zfcp_port *port = send_ct->port;
  485. struct zfcp_adapter *adapter = port->adapter;
  486. struct ct_hdr *header = (struct ct_hdr *)buffer;
  487. struct zfcp_san_dbf_record *rec = &adapter->san_dbf_buf;
  488. struct zfcp_san_dbf_record_ct *ct = &rec->type.ct;
  489. unsigned long flags;
  490. spin_lock_irqsave(&adapter->san_dbf_lock, flags);
  491. memset(rec, 0, sizeof(struct zfcp_san_dbf_record));
  492. strncpy(rec->tag, tag, ZFCP_DBF_TAG_SIZE);
  493. rec->fsf_reqid = (unsigned long)fsf_req;
  494. rec->fsf_seqno = fsf_req->seq_no;
  495. rec->s_id = s_id;
  496. rec->d_id = d_id;
  497. if (strncmp(tag, "octc", ZFCP_DBF_TAG_SIZE) == 0) {
  498. ct->type.request.cmd_req_code = header->cmd_rsp_code;
  499. ct->type.request.revision = header->revision;
  500. ct->type.request.gs_type = header->gs_type;
  501. ct->type.request.gs_subtype = header->gs_subtype;
  502. ct->type.request.options = header->options;
  503. ct->type.request.max_res_size = header->max_res_size;
  504. } else if (strncmp(tag, "rctc", ZFCP_DBF_TAG_SIZE) == 0) {
  505. ct->type.response.cmd_rsp_code = header->cmd_rsp_code;
  506. ct->type.response.revision = header->revision;
  507. ct->type.response.reason_code = header->reason_code;
  508. ct->type.response.reason_code_expl = header->reason_code_expl;
  509. ct->type.response.vendor_unique = header->vendor_unique;
  510. }
  511. ct->payload_size =
  512. min(buflen - (int)sizeof(struct ct_hdr), ZFCP_DBF_CT_PAYLOAD);
  513. memcpy(ct->payload, buffer + sizeof(struct ct_hdr), ct->payload_size);
  514. debug_event(adapter->san_dbf, 3,
  515. rec, sizeof(struct zfcp_san_dbf_record));
  516. spin_unlock_irqrestore(&adapter->san_dbf_lock, flags);
  517. }
  518. void zfcp_san_dbf_event_ct_request(struct zfcp_fsf_req *fsf_req)
  519. {
  520. struct zfcp_send_ct *ct = (struct zfcp_send_ct *)fsf_req->data;
  521. struct zfcp_port *port = ct->port;
  522. struct zfcp_adapter *adapter = port->adapter;
  523. _zfcp_san_dbf_event_common_ct("octc", fsf_req,
  524. fc_host_port_id(adapter->scsi_host),
  525. port->d_id, zfcp_sg_to_address(ct->req),
  526. ct->req->length);
  527. }
  528. void zfcp_san_dbf_event_ct_response(struct zfcp_fsf_req *fsf_req)
  529. {
  530. struct zfcp_send_ct *ct = (struct zfcp_send_ct *)fsf_req->data;
  531. struct zfcp_port *port = ct->port;
  532. struct zfcp_adapter *adapter = port->adapter;
  533. _zfcp_san_dbf_event_common_ct("rctc", fsf_req, port->d_id,
  534. fc_host_port_id(adapter->scsi_host),
  535. zfcp_sg_to_address(ct->resp),
  536. ct->resp->length);
  537. }
  538. static void
  539. _zfcp_san_dbf_event_common_els(const char *tag, int level,
  540. struct zfcp_fsf_req *fsf_req, u32 s_id,
  541. u32 d_id, u8 ls_code, void *buffer, int buflen)
  542. {
  543. struct zfcp_adapter *adapter = fsf_req->adapter;
  544. struct zfcp_san_dbf_record *rec = &adapter->san_dbf_buf;
  545. unsigned long flags;
  546. spin_lock_irqsave(&adapter->san_dbf_lock, flags);
  547. memset(rec, 0, sizeof(struct zfcp_san_dbf_record));
  548. strncpy(rec->tag, tag, ZFCP_DBF_TAG_SIZE);
  549. rec->fsf_reqid = (unsigned long)fsf_req;
  550. rec->fsf_seqno = fsf_req->seq_no;
  551. rec->s_id = s_id;
  552. rec->d_id = d_id;
  553. rec->type.els.ls_code = ls_code;
  554. debug_event(adapter->san_dbf, level, rec, sizeof(*rec));
  555. zfcp_dbf_hexdump(adapter->san_dbf, rec, sizeof(*rec), level,
  556. buffer, min(buflen, ZFCP_DBF_ELS_MAX_PAYLOAD));
  557. spin_unlock_irqrestore(&adapter->san_dbf_lock, flags);
  558. }
  559. void zfcp_san_dbf_event_els_request(struct zfcp_fsf_req *fsf_req)
  560. {
  561. struct zfcp_send_els *els = (struct zfcp_send_els *)fsf_req->data;
  562. _zfcp_san_dbf_event_common_els("oels", 2, fsf_req,
  563. fc_host_port_id(els->adapter->scsi_host),
  564. els->d_id,
  565. *(u8 *) zfcp_sg_to_address(els->req),
  566. zfcp_sg_to_address(els->req),
  567. els->req->length);
  568. }
  569. void zfcp_san_dbf_event_els_response(struct zfcp_fsf_req *fsf_req)
  570. {
  571. struct zfcp_send_els *els = (struct zfcp_send_els *)fsf_req->data;
  572. _zfcp_san_dbf_event_common_els("rels", 2, fsf_req, els->d_id,
  573. fc_host_port_id(els->adapter->scsi_host),
  574. *(u8 *) zfcp_sg_to_address(els->req),
  575. zfcp_sg_to_address(els->resp),
  576. els->resp->length);
  577. }
  578. void zfcp_san_dbf_event_incoming_els(struct zfcp_fsf_req *fsf_req)
  579. {
  580. struct zfcp_adapter *adapter = fsf_req->adapter;
  581. struct fsf_status_read_buffer *status_buffer =
  582. (struct fsf_status_read_buffer *)fsf_req->data;
  583. int length = (int)status_buffer->length -
  584. (int)((void *)&status_buffer->payload - (void *)status_buffer);
  585. _zfcp_san_dbf_event_common_els("iels", 1, fsf_req, status_buffer->d_id,
  586. fc_host_port_id(adapter->scsi_host),
  587. *(u8 *) status_buffer->payload,
  588. (void *)status_buffer->payload, length);
  589. }
  590. static int
  591. zfcp_san_dbf_view_format(debug_info_t * id, struct debug_view *view,
  592. char *out_buf, const char *in_buf)
  593. {
  594. struct zfcp_san_dbf_record *rec = (struct zfcp_san_dbf_record *)in_buf;
  595. char *buffer = NULL;
  596. int buflen = 0, total = 0;
  597. int len = 0;
  598. if (strncmp(rec->tag, "dump", ZFCP_DBF_TAG_SIZE) == 0)
  599. return 0;
  600. len += zfcp_dbf_tag(out_buf + len, "tag", rec->tag);
  601. len += zfcp_dbf_view(out_buf + len, "fsf_reqid", "0x%0Lx",
  602. rec->fsf_reqid);
  603. len += zfcp_dbf_view(out_buf + len, "fsf_seqno", "0x%08x",
  604. rec->fsf_seqno);
  605. len += zfcp_dbf_view(out_buf + len, "s_id", "0x%06x", rec->s_id);
  606. len += zfcp_dbf_view(out_buf + len, "d_id", "0x%06x", rec->d_id);
  607. if (strncmp(rec->tag, "octc", ZFCP_DBF_TAG_SIZE) == 0) {
  608. len += zfcp_dbf_view(out_buf + len, "cmd_req_code", "0x%04x",
  609. rec->type.ct.type.request.cmd_req_code);
  610. len += zfcp_dbf_view(out_buf + len, "revision", "0x%02x",
  611. rec->type.ct.type.request.revision);
  612. len += zfcp_dbf_view(out_buf + len, "gs_type", "0x%02x",
  613. rec->type.ct.type.request.gs_type);
  614. len += zfcp_dbf_view(out_buf + len, "gs_subtype", "0x%02x",
  615. rec->type.ct.type.request.gs_subtype);
  616. len += zfcp_dbf_view(out_buf + len, "options", "0x%02x",
  617. rec->type.ct.type.request.options);
  618. len += zfcp_dbf_view(out_buf + len, "max_res_size", "0x%04x",
  619. rec->type.ct.type.request.max_res_size);
  620. total = rec->type.ct.payload_size;
  621. buffer = rec->type.ct.payload;
  622. buflen = min(total, ZFCP_DBF_CT_PAYLOAD);
  623. } else if (strncmp(rec->tag, "rctc", ZFCP_DBF_TAG_SIZE) == 0) {
  624. len += zfcp_dbf_view(out_buf + len, "cmd_rsp_code", "0x%04x",
  625. rec->type.ct.type.response.cmd_rsp_code);
  626. len += zfcp_dbf_view(out_buf + len, "revision", "0x%02x",
  627. rec->type.ct.type.response.revision);
  628. len += zfcp_dbf_view(out_buf + len, "reason_code", "0x%02x",
  629. rec->type.ct.type.response.reason_code);
  630. len +=
  631. zfcp_dbf_view(out_buf + len, "reason_code_expl", "0x%02x",
  632. rec->type.ct.type.response.reason_code_expl);
  633. len +=
  634. zfcp_dbf_view(out_buf + len, "vendor_unique", "0x%02x",
  635. rec->type.ct.type.response.vendor_unique);
  636. total = rec->type.ct.payload_size;
  637. buffer = rec->type.ct.payload;
  638. buflen = min(total, ZFCP_DBF_CT_PAYLOAD);
  639. } else if (strncmp(rec->tag, "oels", ZFCP_DBF_TAG_SIZE) == 0 ||
  640. strncmp(rec->tag, "rels", ZFCP_DBF_TAG_SIZE) == 0 ||
  641. strncmp(rec->tag, "iels", ZFCP_DBF_TAG_SIZE) == 0) {
  642. len += zfcp_dbf_view(out_buf + len, "ls_code", "0x%02x",
  643. rec->type.els.ls_code);
  644. total = rec->type.els.payload_size;
  645. buffer = rec->type.els.payload;
  646. buflen = min(total, ZFCP_DBF_ELS_PAYLOAD);
  647. }
  648. len += zfcp_dbf_view_dump(out_buf + len, "payload",
  649. buffer, buflen, 0, total);
  650. if (buflen == total)
  651. len += sprintf(out_buf + len, "\n");
  652. return len;
  653. }
  654. static struct debug_view zfcp_san_dbf_view = {
  655. "structured",
  656. NULL,
  657. &zfcp_dbf_view_header,
  658. &zfcp_san_dbf_view_format,
  659. NULL,
  660. NULL
  661. };
  662. static void
  663. _zfcp_scsi_dbf_event_common(const char *tag, const char *tag2, int level,
  664. struct zfcp_adapter *adapter,
  665. struct scsi_cmnd *scsi_cmnd,
  666. struct zfcp_fsf_req *fsf_req,
  667. unsigned long old_req_id)
  668. {
  669. struct zfcp_scsi_dbf_record *rec = &adapter->scsi_dbf_buf;
  670. struct zfcp_dbf_dump *dump = (struct zfcp_dbf_dump *)rec;
  671. unsigned long flags;
  672. struct fcp_rsp_iu *fcp_rsp;
  673. char *fcp_rsp_info = NULL, *fcp_sns_info = NULL;
  674. int offset = 0, buflen = 0;
  675. spin_lock_irqsave(&adapter->scsi_dbf_lock, flags);
  676. do {
  677. memset(rec, 0, sizeof(struct zfcp_scsi_dbf_record));
  678. if (offset == 0) {
  679. strncpy(rec->tag, tag, ZFCP_DBF_TAG_SIZE);
  680. strncpy(rec->tag2, tag2, ZFCP_DBF_TAG_SIZE);
  681. if (scsi_cmnd != NULL) {
  682. if (scsi_cmnd->device) {
  683. rec->scsi_id = scsi_cmnd->device->id;
  684. rec->scsi_lun = scsi_cmnd->device->lun;
  685. }
  686. rec->scsi_result = scsi_cmnd->result;
  687. rec->scsi_cmnd = (unsigned long)scsi_cmnd;
  688. rec->scsi_serial = scsi_cmnd->serial_number;
  689. memcpy(rec->scsi_opcode, &scsi_cmnd->cmnd,
  690. min((int)scsi_cmnd->cmd_len,
  691. ZFCP_DBF_SCSI_OPCODE));
  692. rec->scsi_retries = scsi_cmnd->retries;
  693. rec->scsi_allowed = scsi_cmnd->allowed;
  694. }
  695. if (fsf_req != NULL) {
  696. fcp_rsp = (struct fcp_rsp_iu *)
  697. &(fsf_req->qtcb->bottom.io.fcp_rsp);
  698. fcp_rsp_info =
  699. zfcp_get_fcp_rsp_info_ptr(fcp_rsp);
  700. fcp_sns_info =
  701. zfcp_get_fcp_sns_info_ptr(fcp_rsp);
  702. rec->type.fcp.rsp_validity =
  703. fcp_rsp->validity.value;
  704. rec->type.fcp.rsp_scsi_status =
  705. fcp_rsp->scsi_status;
  706. rec->type.fcp.rsp_resid = fcp_rsp->fcp_resid;
  707. if (fcp_rsp->validity.bits.fcp_rsp_len_valid)
  708. rec->type.fcp.rsp_code =
  709. *(fcp_rsp_info + 3);
  710. if (fcp_rsp->validity.bits.fcp_sns_len_valid) {
  711. buflen = min((int)fcp_rsp->fcp_sns_len,
  712. ZFCP_DBF_SCSI_MAX_FCP_SNS_INFO);
  713. rec->type.fcp.sns_info_len = buflen;
  714. memcpy(rec->type.fcp.sns_info,
  715. fcp_sns_info,
  716. min(buflen,
  717. ZFCP_DBF_SCSI_FCP_SNS_INFO));
  718. offset += min(buflen,
  719. ZFCP_DBF_SCSI_FCP_SNS_INFO);
  720. }
  721. rec->fsf_reqid = (unsigned long)fsf_req;
  722. rec->fsf_seqno = fsf_req->seq_no;
  723. rec->fsf_issued = fsf_req->issued;
  724. }
  725. rec->type.old_fsf_reqid = old_req_id;
  726. } else {
  727. strncpy(dump->tag, "dump", ZFCP_DBF_TAG_SIZE);
  728. dump->total_size = buflen;
  729. dump->offset = offset;
  730. dump->size = min(buflen - offset,
  731. (int)sizeof(struct
  732. zfcp_scsi_dbf_record) -
  733. (int)sizeof(struct zfcp_dbf_dump));
  734. memcpy(dump->data, fcp_sns_info + offset, dump->size);
  735. offset += dump->size;
  736. }
  737. debug_event(adapter->scsi_dbf, level,
  738. rec, sizeof(struct zfcp_scsi_dbf_record));
  739. } while (offset < buflen);
  740. spin_unlock_irqrestore(&adapter->scsi_dbf_lock, flags);
  741. }
  742. void
  743. zfcp_scsi_dbf_event_result(const char *tag, int level,
  744. struct zfcp_adapter *adapter,
  745. struct scsi_cmnd *scsi_cmnd,
  746. struct zfcp_fsf_req *fsf_req)
  747. {
  748. _zfcp_scsi_dbf_event_common("rslt", tag, level,
  749. adapter, scsi_cmnd, fsf_req, 0);
  750. }
  751. void
  752. zfcp_scsi_dbf_event_abort(const char *tag, struct zfcp_adapter *adapter,
  753. struct scsi_cmnd *scsi_cmnd,
  754. struct zfcp_fsf_req *new_fsf_req,
  755. unsigned long old_req_id)
  756. {
  757. _zfcp_scsi_dbf_event_common("abrt", tag, 1,
  758. adapter, scsi_cmnd, new_fsf_req, old_req_id);
  759. }
  760. void
  761. zfcp_scsi_dbf_event_devreset(const char *tag, u8 flag, struct zfcp_unit *unit,
  762. struct scsi_cmnd *scsi_cmnd)
  763. {
  764. struct zfcp_adapter *adapter = unit->port->adapter;
  765. _zfcp_scsi_dbf_event_common(flag == FCP_TARGET_RESET ? "trst" : "lrst",
  766. tag, 1, adapter, scsi_cmnd, NULL, 0);
  767. }
  768. static int
  769. zfcp_scsi_dbf_view_format(debug_info_t * id, struct debug_view *view,
  770. char *out_buf, const char *in_buf)
  771. {
  772. struct zfcp_scsi_dbf_record *rec =
  773. (struct zfcp_scsi_dbf_record *)in_buf;
  774. int len = 0;
  775. if (strncmp(rec->tag, "dump", ZFCP_DBF_TAG_SIZE) == 0)
  776. return 0;
  777. len += zfcp_dbf_tag(out_buf + len, "tag", rec->tag);
  778. len += zfcp_dbf_tag(out_buf + len, "tag2", rec->tag2);
  779. len += zfcp_dbf_view(out_buf + len, "scsi_id", "0x%08x", rec->scsi_id);
  780. len += zfcp_dbf_view(out_buf + len, "scsi_lun", "0x%08x",
  781. rec->scsi_lun);
  782. len += zfcp_dbf_view(out_buf + len, "scsi_result", "0x%08x",
  783. rec->scsi_result);
  784. len += zfcp_dbf_view(out_buf + len, "scsi_cmnd", "0x%0Lx",
  785. rec->scsi_cmnd);
  786. len += zfcp_dbf_view(out_buf + len, "scsi_serial", "0x%016Lx",
  787. rec->scsi_serial);
  788. len += zfcp_dbf_view_dump(out_buf + len, "scsi_opcode",
  789. rec->scsi_opcode,
  790. ZFCP_DBF_SCSI_OPCODE,
  791. 0, ZFCP_DBF_SCSI_OPCODE);
  792. len += zfcp_dbf_view(out_buf + len, "scsi_retries", "0x%02x",
  793. rec->scsi_retries);
  794. len += zfcp_dbf_view(out_buf + len, "scsi_allowed", "0x%02x",
  795. rec->scsi_allowed);
  796. if (strncmp(rec->tag, "abrt", ZFCP_DBF_TAG_SIZE) == 0) {
  797. len += zfcp_dbf_view(out_buf + len, "old_fsf_reqid", "0x%0Lx",
  798. rec->type.old_fsf_reqid);
  799. }
  800. len += zfcp_dbf_view(out_buf + len, "fsf_reqid", "0x%0Lx",
  801. rec->fsf_reqid);
  802. len += zfcp_dbf_view(out_buf + len, "fsf_seqno", "0x%08x",
  803. rec->fsf_seqno);
  804. len += zfcp_dbf_stck(out_buf + len, "fsf_issued", rec->fsf_issued);
  805. if (strncmp(rec->tag, "rslt", ZFCP_DBF_TAG_SIZE) == 0) {
  806. len +=
  807. zfcp_dbf_view(out_buf + len, "fcp_rsp_validity", "0x%02x",
  808. rec->type.fcp.rsp_validity);
  809. len +=
  810. zfcp_dbf_view(out_buf + len, "fcp_rsp_scsi_status",
  811. "0x%02x", rec->type.fcp.rsp_scsi_status);
  812. len +=
  813. zfcp_dbf_view(out_buf + len, "fcp_rsp_resid", "0x%08x",
  814. rec->type.fcp.rsp_resid);
  815. len +=
  816. zfcp_dbf_view(out_buf + len, "fcp_rsp_code", "0x%08x",
  817. rec->type.fcp.rsp_code);
  818. len +=
  819. zfcp_dbf_view(out_buf + len, "fcp_sns_info_len", "0x%08x",
  820. rec->type.fcp.sns_info_len);
  821. len +=
  822. zfcp_dbf_view_dump(out_buf + len, "fcp_sns_info",
  823. rec->type.fcp.sns_info,
  824. min((int)rec->type.fcp.sns_info_len,
  825. ZFCP_DBF_SCSI_FCP_SNS_INFO), 0,
  826. rec->type.fcp.sns_info_len);
  827. }
  828. len += sprintf(out_buf + len, "\n");
  829. return len;
  830. }
  831. static struct debug_view zfcp_scsi_dbf_view = {
  832. "structured",
  833. NULL,
  834. &zfcp_dbf_view_header,
  835. &zfcp_scsi_dbf_view_format,
  836. NULL,
  837. NULL
  838. };
  839. /**
  840. * zfcp_adapter_debug_register - registers debug feature for an adapter
  841. * @adapter: pointer to adapter for which debug features should be registered
  842. * return: -ENOMEM on error, 0 otherwise
  843. */
  844. int zfcp_adapter_debug_register(struct zfcp_adapter *adapter)
  845. {
  846. char dbf_name[DEBUG_MAX_NAME_LEN];
  847. /* debug feature area which records recovery activity */
  848. sprintf(dbf_name, "zfcp_%s_erp", zfcp_get_busid_by_adapter(adapter));
  849. adapter->erp_dbf = debug_register(dbf_name, dbfsize, 2,
  850. sizeof(struct zfcp_erp_dbf_record));
  851. if (!adapter->erp_dbf)
  852. goto failed;
  853. debug_register_view(adapter->erp_dbf, &debug_hex_ascii_view);
  854. debug_set_level(adapter->erp_dbf, 3);
  855. /* debug feature area which records recovery activity */
  856. sprintf(dbf_name, "zfcp_%s_rec", zfcp_get_busid_by_adapter(adapter));
  857. adapter->rec_dbf = debug_register(dbf_name, dbfsize, 1,
  858. sizeof(struct zfcp_rec_dbf_record));
  859. if (!adapter->rec_dbf)
  860. goto failed;
  861. debug_register_view(adapter->rec_dbf, &debug_hex_ascii_view);
  862. debug_register_view(adapter->rec_dbf, &zfcp_rec_dbf_view);
  863. debug_set_level(adapter->rec_dbf, 3);
  864. /* debug feature area which records HBA (FSF and QDIO) conditions */
  865. sprintf(dbf_name, "zfcp_%s_hba", zfcp_get_busid_by_adapter(adapter));
  866. adapter->hba_dbf = debug_register(dbf_name, dbfsize, 1,
  867. sizeof(struct zfcp_hba_dbf_record));
  868. if (!adapter->hba_dbf)
  869. goto failed;
  870. debug_register_view(adapter->hba_dbf, &debug_hex_ascii_view);
  871. debug_register_view(adapter->hba_dbf, &zfcp_hba_dbf_view);
  872. debug_set_level(adapter->hba_dbf, 3);
  873. /* debug feature area which records SAN command failures and recovery */
  874. sprintf(dbf_name, "zfcp_%s_san", zfcp_get_busid_by_adapter(adapter));
  875. adapter->san_dbf = debug_register(dbf_name, dbfsize, 1,
  876. sizeof(struct zfcp_san_dbf_record));
  877. if (!adapter->san_dbf)
  878. goto failed;
  879. debug_register_view(adapter->san_dbf, &debug_hex_ascii_view);
  880. debug_register_view(adapter->san_dbf, &zfcp_san_dbf_view);
  881. debug_set_level(adapter->san_dbf, 6);
  882. /* debug feature area which records SCSI command failures and recovery */
  883. sprintf(dbf_name, "zfcp_%s_scsi", zfcp_get_busid_by_adapter(adapter));
  884. adapter->scsi_dbf = debug_register(dbf_name, dbfsize, 1,
  885. sizeof(struct zfcp_scsi_dbf_record));
  886. if (!adapter->scsi_dbf)
  887. goto failed;
  888. debug_register_view(adapter->scsi_dbf, &debug_hex_ascii_view);
  889. debug_register_view(adapter->scsi_dbf, &zfcp_scsi_dbf_view);
  890. debug_set_level(adapter->scsi_dbf, 3);
  891. return 0;
  892. failed:
  893. zfcp_adapter_debug_unregister(adapter);
  894. return -ENOMEM;
  895. }
  896. /**
  897. * zfcp_adapter_debug_unregister - unregisters debug feature for an adapter
  898. * @adapter: pointer to adapter for which debug features should be unregistered
  899. */
  900. void zfcp_adapter_debug_unregister(struct zfcp_adapter *adapter)
  901. {
  902. debug_unregister(adapter->scsi_dbf);
  903. debug_unregister(adapter->san_dbf);
  904. debug_unregister(adapter->hba_dbf);
  905. debug_unregister(adapter->rec_dbf);
  906. debug_unregister(adapter->erp_dbf);
  907. adapter->scsi_dbf = NULL;
  908. adapter->san_dbf = NULL;
  909. adapter->hba_dbf = NULL;
  910. adapter->rec_dbf = NULL;
  911. adapter->erp_dbf = NULL;
  912. }
  913. #undef ZFCP_LOG_AREA