zfcp_dbf.c 32 KB

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