zfcp_dbf.c 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988
  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. rec->type.status.payload_size = sizeof(u64);
  245. break;
  246. }
  247. memcpy(&rec->type.status.payload,
  248. &status_buffer->payload, rec->type.status.payload_size);
  249. }
  250. debug_event(adapter->hba_dbf, 2,
  251. rec, sizeof(struct zfcp_hba_dbf_record));
  252. spin_unlock_irqrestore(&adapter->hba_dbf_lock, flags);
  253. }
  254. inline void
  255. zfcp_hba_dbf_event_qdio(struct zfcp_adapter *adapter, unsigned int status,
  256. unsigned int qdio_error, unsigned int siga_error,
  257. int sbal_index, int sbal_count)
  258. {
  259. struct zfcp_hba_dbf_record *rec = &adapter->hba_dbf_buf;
  260. unsigned long flags;
  261. spin_lock_irqsave(&adapter->hba_dbf_lock, flags);
  262. memset(rec, 0, sizeof(struct zfcp_hba_dbf_record));
  263. strncpy(rec->tag, "qdio", ZFCP_DBF_TAG_SIZE);
  264. rec->type.qdio.status = status;
  265. rec->type.qdio.qdio_error = qdio_error;
  266. rec->type.qdio.siga_error = siga_error;
  267. rec->type.qdio.sbal_index = sbal_index;
  268. rec->type.qdio.sbal_count = sbal_count;
  269. debug_event(adapter->hba_dbf, 0,
  270. rec, sizeof(struct zfcp_hba_dbf_record));
  271. spin_unlock_irqrestore(&adapter->hba_dbf_lock, flags);
  272. }
  273. static inline int
  274. zfcp_hba_dbf_view_response(char *out_buf,
  275. struct zfcp_hba_dbf_record_response *rec)
  276. {
  277. int len = 0;
  278. len += zfcp_dbf_view(out_buf + len, "fsf_command", "0x%08x",
  279. rec->fsf_command);
  280. len += zfcp_dbf_view(out_buf + len, "fsf_reqid", "0x%0Lx",
  281. rec->fsf_reqid);
  282. len += zfcp_dbf_view(out_buf + len, "fsf_seqno", "0x%08x",
  283. rec->fsf_seqno);
  284. len += zfcp_dbf_stck(out_buf + len, "fsf_issued", rec->fsf_issued);
  285. len += zfcp_dbf_view(out_buf + len, "fsf_prot_status", "0x%08x",
  286. rec->fsf_prot_status);
  287. len += zfcp_dbf_view(out_buf + len, "fsf_status", "0x%08x",
  288. rec->fsf_status);
  289. len += zfcp_dbf_view_dump(out_buf + len, "fsf_prot_status_qual",
  290. rec->fsf_prot_status_qual,
  291. FSF_PROT_STATUS_QUAL_SIZE,
  292. 0, FSF_PROT_STATUS_QUAL_SIZE);
  293. len += zfcp_dbf_view_dump(out_buf + len, "fsf_status_qual",
  294. rec->fsf_status_qual,
  295. FSF_STATUS_QUALIFIER_SIZE,
  296. 0, FSF_STATUS_QUALIFIER_SIZE);
  297. len += zfcp_dbf_view(out_buf + len, "fsf_req_status", "0x%08x",
  298. rec->fsf_req_status);
  299. len += zfcp_dbf_view(out_buf + len, "sbal_first", "0x%02x",
  300. rec->sbal_first);
  301. len += zfcp_dbf_view(out_buf + len, "sbal_curr", "0x%02x",
  302. rec->sbal_curr);
  303. len += zfcp_dbf_view(out_buf + len, "sbal_last", "0x%02x",
  304. rec->sbal_last);
  305. len += zfcp_dbf_view(out_buf + len, "pool", "0x%02x", rec->pool);
  306. switch (rec->fsf_command) {
  307. case FSF_QTCB_FCP_CMND:
  308. if (rec->fsf_req_status & ZFCP_STATUS_FSFREQ_TASK_MANAGEMENT)
  309. break;
  310. len += zfcp_dbf_view(out_buf + len, "scsi_cmnd", "0x%0Lx",
  311. rec->data.send_fcp.scsi_cmnd);
  312. len += zfcp_dbf_view(out_buf + len, "scsi_serial", "0x%016Lx",
  313. rec->data.send_fcp.scsi_serial);
  314. break;
  315. case FSF_QTCB_OPEN_PORT_WITH_DID:
  316. case FSF_QTCB_CLOSE_PORT:
  317. case FSF_QTCB_CLOSE_PHYSICAL_PORT:
  318. len += zfcp_dbf_view(out_buf + len, "wwpn", "0x%016Lx",
  319. rec->data.port.wwpn);
  320. len += zfcp_dbf_view(out_buf + len, "d_id", "0x%06x",
  321. rec->data.port.d_id);
  322. len += zfcp_dbf_view(out_buf + len, "port_handle", "0x%08x",
  323. rec->data.port.port_handle);
  324. break;
  325. case FSF_QTCB_OPEN_LUN:
  326. case FSF_QTCB_CLOSE_LUN:
  327. len += zfcp_dbf_view(out_buf + len, "wwpn", "0x%016Lx",
  328. rec->data.unit.wwpn);
  329. len += zfcp_dbf_view(out_buf + len, "fcp_lun", "0x%016Lx",
  330. rec->data.unit.fcp_lun);
  331. len += zfcp_dbf_view(out_buf + len, "port_handle", "0x%08x",
  332. rec->data.unit.port_handle);
  333. len += zfcp_dbf_view(out_buf + len, "lun_handle", "0x%08x",
  334. rec->data.unit.lun_handle);
  335. break;
  336. case FSF_QTCB_SEND_ELS:
  337. len += zfcp_dbf_view(out_buf + len, "d_id", "0x%06x",
  338. rec->data.send_els.d_id);
  339. len += zfcp_dbf_view(out_buf + len, "ls_code", "0x%02x",
  340. rec->data.send_els.ls_code);
  341. break;
  342. case FSF_QTCB_ABORT_FCP_CMND:
  343. case FSF_QTCB_SEND_GENERIC:
  344. case FSF_QTCB_EXCHANGE_CONFIG_DATA:
  345. case FSF_QTCB_EXCHANGE_PORT_DATA:
  346. case FSF_QTCB_DOWNLOAD_CONTROL_FILE:
  347. case FSF_QTCB_UPLOAD_CONTROL_FILE:
  348. break;
  349. }
  350. return len;
  351. }
  352. static inline int
  353. zfcp_hba_dbf_view_status(char *out_buf, struct zfcp_hba_dbf_record_status *rec)
  354. {
  355. int len = 0;
  356. len += zfcp_dbf_view(out_buf + len, "failed", "0x%02x", rec->failed);
  357. len += zfcp_dbf_view(out_buf + len, "status_type", "0x%08x",
  358. rec->status_type);
  359. len += zfcp_dbf_view(out_buf + len, "status_subtype", "0x%08x",
  360. rec->status_subtype);
  361. len += zfcp_dbf_view_dump(out_buf + len, "queue_designator",
  362. (char *)&rec->queue_designator,
  363. sizeof(struct fsf_queue_designator),
  364. 0, sizeof(struct fsf_queue_designator));
  365. len += zfcp_dbf_view_dump(out_buf + len, "payload",
  366. (char *)&rec->payload,
  367. rec->payload_size, 0, rec->payload_size);
  368. return len;
  369. }
  370. static inline int
  371. zfcp_hba_dbf_view_qdio(char *out_buf, struct zfcp_hba_dbf_record_qdio *rec)
  372. {
  373. int len = 0;
  374. len += zfcp_dbf_view(out_buf + len, "status", "0x%08x", rec->status);
  375. len += zfcp_dbf_view(out_buf + len, "qdio_error", "0x%08x",
  376. rec->qdio_error);
  377. len += zfcp_dbf_view(out_buf + len, "siga_error", "0x%08x",
  378. rec->siga_error);
  379. len += zfcp_dbf_view(out_buf + len, "sbal_index", "0x%02x",
  380. rec->sbal_index);
  381. len += zfcp_dbf_view(out_buf + len, "sbal_count", "0x%02x",
  382. rec->sbal_count);
  383. return len;
  384. }
  385. static int
  386. zfcp_hba_dbf_view_format(debug_info_t * id, struct debug_view *view,
  387. char *out_buf, const char *in_buf)
  388. {
  389. struct zfcp_hba_dbf_record *rec = (struct zfcp_hba_dbf_record *)in_buf;
  390. int len = 0;
  391. if (strncmp(rec->tag, "dump", ZFCP_DBF_TAG_SIZE) == 0)
  392. return 0;
  393. len += zfcp_dbf_tag(out_buf + len, "tag", rec->tag);
  394. if (isalpha(rec->tag2[0]))
  395. len += zfcp_dbf_tag(out_buf + len, "tag2", rec->tag2);
  396. if (strncmp(rec->tag, "resp", ZFCP_DBF_TAG_SIZE) == 0)
  397. len += zfcp_hba_dbf_view_response(out_buf + len,
  398. &rec->type.response);
  399. else if (strncmp(rec->tag, "stat", ZFCP_DBF_TAG_SIZE) == 0)
  400. len += zfcp_hba_dbf_view_status(out_buf + len,
  401. &rec->type.status);
  402. else if (strncmp(rec->tag, "qdio", ZFCP_DBF_TAG_SIZE) == 0)
  403. len += zfcp_hba_dbf_view_qdio(out_buf + len, &rec->type.qdio);
  404. len += sprintf(out_buf + len, "\n");
  405. return len;
  406. }
  407. struct debug_view zfcp_hba_dbf_view = {
  408. "structured",
  409. NULL,
  410. &zfcp_dbf_view_header,
  411. &zfcp_hba_dbf_view_format,
  412. NULL,
  413. NULL
  414. };
  415. inline void
  416. _zfcp_san_dbf_event_common_ct(const char *tag, struct zfcp_fsf_req *fsf_req,
  417. fc_id_t s_id, fc_id_t d_id,
  418. void *buffer, int buflen)
  419. {
  420. struct zfcp_send_ct *send_ct = (struct zfcp_send_ct *)fsf_req->data;
  421. struct zfcp_port *port = send_ct->port;
  422. struct zfcp_adapter *adapter = port->adapter;
  423. struct ct_hdr *header = (struct ct_hdr *)buffer;
  424. struct zfcp_san_dbf_record *rec = &adapter->san_dbf_buf;
  425. struct zfcp_san_dbf_record_ct *ct = &rec->type.ct;
  426. unsigned long flags;
  427. spin_lock_irqsave(&adapter->san_dbf_lock, flags);
  428. memset(rec, 0, sizeof(struct zfcp_san_dbf_record));
  429. strncpy(rec->tag, tag, ZFCP_DBF_TAG_SIZE);
  430. rec->fsf_reqid = (unsigned long)fsf_req;
  431. rec->fsf_seqno = fsf_req->seq_no;
  432. rec->s_id = s_id;
  433. rec->d_id = d_id;
  434. if (strncmp(tag, "octc", ZFCP_DBF_TAG_SIZE) == 0) {
  435. ct->type.request.cmd_req_code = header->cmd_rsp_code;
  436. ct->type.request.revision = header->revision;
  437. ct->type.request.gs_type = header->gs_type;
  438. ct->type.request.gs_subtype = header->gs_subtype;
  439. ct->type.request.options = header->options;
  440. ct->type.request.max_res_size = header->max_res_size;
  441. } else if (strncmp(tag, "rctc", ZFCP_DBF_TAG_SIZE) == 0) {
  442. ct->type.response.cmd_rsp_code = header->cmd_rsp_code;
  443. ct->type.response.revision = header->revision;
  444. ct->type.response.reason_code = header->reason_code;
  445. ct->type.response.reason_code_expl = header->reason_code_expl;
  446. ct->type.response.vendor_unique = header->vendor_unique;
  447. }
  448. ct->payload_size =
  449. min(buflen - (int)sizeof(struct ct_hdr), ZFCP_DBF_CT_PAYLOAD);
  450. memcpy(ct->payload, buffer + sizeof(struct ct_hdr), ct->payload_size);
  451. debug_event(adapter->san_dbf, 3,
  452. rec, sizeof(struct zfcp_san_dbf_record));
  453. spin_unlock_irqrestore(&adapter->san_dbf_lock, flags);
  454. }
  455. inline void zfcp_san_dbf_event_ct_request(struct zfcp_fsf_req *fsf_req)
  456. {
  457. struct zfcp_send_ct *ct = (struct zfcp_send_ct *)fsf_req->data;
  458. struct zfcp_port *port = ct->port;
  459. struct zfcp_adapter *adapter = port->adapter;
  460. _zfcp_san_dbf_event_common_ct("octc",
  461. fsf_req, adapter->s_id, port->d_id,
  462. zfcp_sg_to_address(ct->req),
  463. ct->req->length);
  464. }
  465. inline void zfcp_san_dbf_event_ct_response(struct zfcp_fsf_req *fsf_req)
  466. {
  467. struct zfcp_send_ct *ct = (struct zfcp_send_ct *)fsf_req->data;
  468. struct zfcp_port *port = ct->port;
  469. struct zfcp_adapter *adapter = port->adapter;
  470. _zfcp_san_dbf_event_common_ct("rctc",
  471. fsf_req, port->d_id, adapter->s_id,
  472. zfcp_sg_to_address(ct->resp),
  473. ct->resp->length);
  474. }
  475. static inline void
  476. _zfcp_san_dbf_event_common_els(const char *tag, int level,
  477. struct zfcp_fsf_req *fsf_req,
  478. fc_id_t s_id, fc_id_t d_id, u8 ls_code,
  479. void *buffer, int buflen)
  480. {
  481. struct zfcp_adapter *adapter = fsf_req->adapter;
  482. struct zfcp_san_dbf_record *rec = &adapter->san_dbf_buf;
  483. struct zfcp_dbf_dump *dump = (struct zfcp_dbf_dump *)rec;
  484. unsigned long flags;
  485. int offset = 0;
  486. spin_lock_irqsave(&adapter->san_dbf_lock, flags);
  487. do {
  488. memset(rec, 0, sizeof(struct zfcp_san_dbf_record));
  489. if (offset == 0) {
  490. strncpy(rec->tag, tag, ZFCP_DBF_TAG_SIZE);
  491. rec->fsf_reqid = (unsigned long)fsf_req;
  492. rec->fsf_seqno = fsf_req->seq_no;
  493. rec->s_id = s_id;
  494. rec->d_id = d_id;
  495. rec->type.els.ls_code = ls_code;
  496. buflen = min(buflen, ZFCP_DBF_ELS_MAX_PAYLOAD);
  497. rec->type.els.payload_size = buflen;
  498. memcpy(rec->type.els.payload,
  499. buffer, min(buflen, ZFCP_DBF_ELS_PAYLOAD));
  500. offset += min(buflen, ZFCP_DBF_ELS_PAYLOAD);
  501. } else {
  502. strncpy(dump->tag, "dump", ZFCP_DBF_TAG_SIZE);
  503. dump->total_size = buflen;
  504. dump->offset = offset;
  505. dump->size = min(buflen - offset,
  506. (int)sizeof(struct zfcp_san_dbf_record)
  507. - (int)sizeof(struct zfcp_dbf_dump));
  508. memcpy(dump->data, buffer + offset, dump->size);
  509. offset += dump->size;
  510. }
  511. debug_event(adapter->san_dbf, level,
  512. rec, sizeof(struct zfcp_san_dbf_record));
  513. } while (offset < buflen);
  514. spin_unlock_irqrestore(&adapter->san_dbf_lock, flags);
  515. }
  516. inline void zfcp_san_dbf_event_els_request(struct zfcp_fsf_req *fsf_req)
  517. {
  518. struct zfcp_send_els *els = (struct zfcp_send_els *)fsf_req->data;
  519. _zfcp_san_dbf_event_common_els("oels", 2,
  520. fsf_req, els->adapter->s_id, els->d_id,
  521. *(u8 *) zfcp_sg_to_address(els->req),
  522. zfcp_sg_to_address(els->req),
  523. els->req->length);
  524. }
  525. inline void zfcp_san_dbf_event_els_response(struct zfcp_fsf_req *fsf_req)
  526. {
  527. struct zfcp_send_els *els = (struct zfcp_send_els *)fsf_req->data;
  528. _zfcp_san_dbf_event_common_els("rels", 2,
  529. fsf_req, els->d_id, els->adapter->s_id,
  530. *(u8 *) zfcp_sg_to_address(els->req),
  531. zfcp_sg_to_address(els->resp),
  532. els->resp->length);
  533. }
  534. inline void zfcp_san_dbf_event_incoming_els(struct zfcp_fsf_req *fsf_req)
  535. {
  536. struct zfcp_adapter *adapter = fsf_req->adapter;
  537. struct fsf_status_read_buffer *status_buffer =
  538. (struct fsf_status_read_buffer *)fsf_req->data;
  539. int length = (int)status_buffer->length -
  540. (int)((void *)&status_buffer->payload - (void *)status_buffer);
  541. _zfcp_san_dbf_event_common_els("iels", 1,
  542. fsf_req, status_buffer->d_id,
  543. adapter->s_id,
  544. *(u8 *) status_buffer->payload,
  545. (void *)status_buffer->payload, length);
  546. }
  547. static int
  548. zfcp_san_dbf_view_format(debug_info_t * id, struct debug_view *view,
  549. char *out_buf, const char *in_buf)
  550. {
  551. struct zfcp_san_dbf_record *rec = (struct zfcp_san_dbf_record *)in_buf;
  552. char *buffer = NULL;
  553. int buflen = 0, total = 0;
  554. int len = 0;
  555. if (strncmp(rec->tag, "dump", ZFCP_DBF_TAG_SIZE) == 0)
  556. return 0;
  557. len += zfcp_dbf_tag(out_buf + len, "tag", rec->tag);
  558. len += zfcp_dbf_view(out_buf + len, "fsf_reqid", "0x%0Lx",
  559. rec->fsf_reqid);
  560. len += zfcp_dbf_view(out_buf + len, "fsf_seqno", "0x%08x",
  561. rec->fsf_seqno);
  562. len += zfcp_dbf_view(out_buf + len, "s_id", "0x%06x", rec->s_id);
  563. len += zfcp_dbf_view(out_buf + len, "d_id", "0x%06x", rec->d_id);
  564. if (strncmp(rec->tag, "octc", ZFCP_DBF_TAG_SIZE) == 0) {
  565. len += zfcp_dbf_view(out_buf + len, "cmd_req_code", "0x%04x",
  566. rec->type.ct.type.request.cmd_req_code);
  567. len += zfcp_dbf_view(out_buf + len, "revision", "0x%02x",
  568. rec->type.ct.type.request.revision);
  569. len += zfcp_dbf_view(out_buf + len, "gs_type", "0x%02x",
  570. rec->type.ct.type.request.gs_type);
  571. len += zfcp_dbf_view(out_buf + len, "gs_subtype", "0x%02x",
  572. rec->type.ct.type.request.gs_subtype);
  573. len += zfcp_dbf_view(out_buf + len, "options", "0x%02x",
  574. rec->type.ct.type.request.options);
  575. len += zfcp_dbf_view(out_buf + len, "max_res_size", "0x%04x",
  576. rec->type.ct.type.request.max_res_size);
  577. total = rec->type.ct.payload_size;
  578. buffer = rec->type.ct.payload;
  579. buflen = min(total, ZFCP_DBF_CT_PAYLOAD);
  580. } else if (strncmp(rec->tag, "rctc", ZFCP_DBF_TAG_SIZE) == 0) {
  581. len += zfcp_dbf_view(out_buf + len, "cmd_rsp_code", "0x%04x",
  582. rec->type.ct.type.response.cmd_rsp_code);
  583. len += zfcp_dbf_view(out_buf + len, "revision", "0x%02x",
  584. rec->type.ct.type.response.revision);
  585. len += zfcp_dbf_view(out_buf + len, "reason_code", "0x%02x",
  586. rec->type.ct.type.response.reason_code);
  587. len +=
  588. zfcp_dbf_view(out_buf + len, "reason_code_expl", "0x%02x",
  589. rec->type.ct.type.response.reason_code_expl);
  590. len +=
  591. zfcp_dbf_view(out_buf + len, "vendor_unique", "0x%02x",
  592. rec->type.ct.type.response.vendor_unique);
  593. total = rec->type.ct.payload_size;
  594. buffer = rec->type.ct.payload;
  595. buflen = min(total, ZFCP_DBF_CT_PAYLOAD);
  596. } else if (strncmp(rec->tag, "oels", ZFCP_DBF_TAG_SIZE) == 0 ||
  597. strncmp(rec->tag, "rels", ZFCP_DBF_TAG_SIZE) == 0 ||
  598. strncmp(rec->tag, "iels", ZFCP_DBF_TAG_SIZE) == 0) {
  599. len += zfcp_dbf_view(out_buf + len, "ls_code", "0x%02x",
  600. rec->type.els.ls_code);
  601. total = rec->type.els.payload_size;
  602. buffer = rec->type.els.payload;
  603. buflen = min(total, ZFCP_DBF_ELS_PAYLOAD);
  604. }
  605. len += zfcp_dbf_view_dump(out_buf + len, "payload",
  606. buffer, buflen, 0, total);
  607. if (buflen == total)
  608. len += sprintf(out_buf + len, "\n");
  609. return len;
  610. }
  611. struct debug_view zfcp_san_dbf_view = {
  612. "structured",
  613. NULL,
  614. &zfcp_dbf_view_header,
  615. &zfcp_san_dbf_view_format,
  616. NULL,
  617. NULL
  618. };
  619. static inline void
  620. _zfcp_scsi_dbf_event_common(const char *tag, const char *tag2, int level,
  621. struct zfcp_adapter *adapter,
  622. struct scsi_cmnd *scsi_cmnd,
  623. struct zfcp_fsf_req *new_fsf_req)
  624. {
  625. struct zfcp_fsf_req *fsf_req =
  626. (struct zfcp_fsf_req *)scsi_cmnd->host_scribble;
  627. struct zfcp_scsi_dbf_record *rec = &adapter->scsi_dbf_buf;
  628. struct zfcp_dbf_dump *dump = (struct zfcp_dbf_dump *)rec;
  629. unsigned long flags;
  630. struct fcp_rsp_iu *fcp_rsp;
  631. char *fcp_rsp_info = NULL, *fcp_sns_info = NULL;
  632. int offset = 0, buflen = 0;
  633. spin_lock_irqsave(&adapter->scsi_dbf_lock, flags);
  634. do {
  635. memset(rec, 0, sizeof(struct zfcp_scsi_dbf_record));
  636. if (offset == 0) {
  637. strncpy(rec->tag, tag, ZFCP_DBF_TAG_SIZE);
  638. strncpy(rec->tag2, tag2, ZFCP_DBF_TAG_SIZE);
  639. if (scsi_cmnd->device) {
  640. rec->scsi_id = scsi_cmnd->device->id;
  641. rec->scsi_lun = scsi_cmnd->device->lun;
  642. }
  643. rec->scsi_result = scsi_cmnd->result;
  644. rec->scsi_cmnd = (unsigned long)scsi_cmnd;
  645. rec->scsi_serial = scsi_cmnd->serial_number;
  646. memcpy(rec->scsi_opcode,
  647. &scsi_cmnd->cmnd,
  648. min((int)scsi_cmnd->cmd_len,
  649. ZFCP_DBF_SCSI_OPCODE));
  650. rec->scsi_retries = scsi_cmnd->retries;
  651. rec->scsi_allowed = scsi_cmnd->allowed;
  652. if (fsf_req != NULL) {
  653. fcp_rsp = (struct fcp_rsp_iu *)
  654. &(fsf_req->qtcb->bottom.io.fcp_rsp);
  655. fcp_rsp_info =
  656. zfcp_get_fcp_rsp_info_ptr(fcp_rsp);
  657. fcp_sns_info =
  658. zfcp_get_fcp_sns_info_ptr(fcp_rsp);
  659. rec->type.fcp.rsp_validity =
  660. fcp_rsp->validity.value;
  661. rec->type.fcp.rsp_scsi_status =
  662. fcp_rsp->scsi_status;
  663. rec->type.fcp.rsp_resid = fcp_rsp->fcp_resid;
  664. if (fcp_rsp->validity.bits.fcp_rsp_len_valid)
  665. rec->type.fcp.rsp_code =
  666. *(fcp_rsp_info + 3);
  667. if (fcp_rsp->validity.bits.fcp_sns_len_valid) {
  668. buflen = min((int)fcp_rsp->fcp_sns_len,
  669. ZFCP_DBF_SCSI_MAX_FCP_SNS_INFO);
  670. rec->type.fcp.sns_info_len = buflen;
  671. memcpy(rec->type.fcp.sns_info,
  672. fcp_sns_info,
  673. min(buflen,
  674. ZFCP_DBF_SCSI_FCP_SNS_INFO));
  675. offset += min(buflen,
  676. ZFCP_DBF_SCSI_FCP_SNS_INFO);
  677. }
  678. rec->fsf_reqid = (unsigned long)fsf_req;
  679. rec->fsf_seqno = fsf_req->seq_no;
  680. rec->fsf_issued = fsf_req->issued;
  681. }
  682. if (new_fsf_req != NULL) {
  683. rec->type.new_fsf_req.fsf_reqid =
  684. (unsigned long)
  685. new_fsf_req;
  686. rec->type.new_fsf_req.fsf_seqno =
  687. new_fsf_req->seq_no;
  688. rec->type.new_fsf_req.fsf_issued =
  689. new_fsf_req->issued;
  690. }
  691. } else {
  692. strncpy(dump->tag, "dump", ZFCP_DBF_TAG_SIZE);
  693. dump->total_size = buflen;
  694. dump->offset = offset;
  695. dump->size = min(buflen - offset,
  696. (int)sizeof(struct
  697. zfcp_scsi_dbf_record) -
  698. (int)sizeof(struct zfcp_dbf_dump));
  699. memcpy(dump->data, fcp_sns_info + offset, dump->size);
  700. offset += dump->size;
  701. }
  702. debug_event(adapter->scsi_dbf, level,
  703. rec, sizeof(struct zfcp_scsi_dbf_record));
  704. } while (offset < buflen);
  705. spin_unlock_irqrestore(&adapter->scsi_dbf_lock, flags);
  706. }
  707. inline void
  708. zfcp_scsi_dbf_event_result(const char *tag, int level,
  709. struct zfcp_adapter *adapter,
  710. struct scsi_cmnd *scsi_cmnd)
  711. {
  712. _zfcp_scsi_dbf_event_common("rslt",
  713. tag, level, adapter, scsi_cmnd, NULL);
  714. }
  715. inline void
  716. zfcp_scsi_dbf_event_abort(const char *tag, struct zfcp_adapter *adapter,
  717. struct scsi_cmnd *scsi_cmnd,
  718. struct zfcp_fsf_req *new_fsf_req)
  719. {
  720. _zfcp_scsi_dbf_event_common("abrt",
  721. tag, 1, adapter, scsi_cmnd, new_fsf_req);
  722. }
  723. inline void
  724. zfcp_scsi_dbf_event_devreset(const char *tag, u8 flag, struct zfcp_unit *unit,
  725. struct scsi_cmnd *scsi_cmnd)
  726. {
  727. struct zfcp_adapter *adapter = unit->port->adapter;
  728. _zfcp_scsi_dbf_event_common(flag == FCP_TARGET_RESET ? "trst" : "lrst",
  729. tag, 1, adapter, scsi_cmnd, NULL);
  730. }
  731. static int
  732. zfcp_scsi_dbf_view_format(debug_info_t * id, struct debug_view *view,
  733. char *out_buf, const char *in_buf)
  734. {
  735. struct zfcp_scsi_dbf_record *rec =
  736. (struct zfcp_scsi_dbf_record *)in_buf;
  737. int len = 0;
  738. if (strncmp(rec->tag, "dump", ZFCP_DBF_TAG_SIZE) == 0)
  739. return 0;
  740. len += zfcp_dbf_tag(out_buf + len, "tag", rec->tag);
  741. len += zfcp_dbf_tag(out_buf + len, "tag2", rec->tag2);
  742. len += zfcp_dbf_view(out_buf + len, "scsi_id", "0x%08x", rec->scsi_id);
  743. len += zfcp_dbf_view(out_buf + len, "scsi_lun", "0x%08x",
  744. rec->scsi_lun);
  745. len += zfcp_dbf_view(out_buf + len, "scsi_result", "0x%08x",
  746. rec->scsi_result);
  747. len += zfcp_dbf_view(out_buf + len, "scsi_cmnd", "0x%0Lx",
  748. rec->scsi_cmnd);
  749. len += zfcp_dbf_view(out_buf + len, "scsi_serial", "0x%016Lx",
  750. rec->scsi_serial);
  751. len += zfcp_dbf_view_dump(out_buf + len, "scsi_opcode",
  752. rec->scsi_opcode,
  753. ZFCP_DBF_SCSI_OPCODE,
  754. 0, ZFCP_DBF_SCSI_OPCODE);
  755. len += zfcp_dbf_view(out_buf + len, "scsi_retries", "0x%02x",
  756. rec->scsi_retries);
  757. len += zfcp_dbf_view(out_buf + len, "scsi_allowed", "0x%02x",
  758. rec->scsi_allowed);
  759. len += zfcp_dbf_view(out_buf + len, "fsf_reqid", "0x%0Lx",
  760. rec->fsf_reqid);
  761. len += zfcp_dbf_view(out_buf + len, "fsf_seqno", "0x%08x",
  762. rec->fsf_seqno);
  763. len += zfcp_dbf_stck(out_buf + len, "fsf_issued", rec->fsf_issued);
  764. if (strncmp(rec->tag, "rslt", ZFCP_DBF_TAG_SIZE) == 0) {
  765. len +=
  766. zfcp_dbf_view(out_buf + len, "fcp_rsp_validity", "0x%02x",
  767. rec->type.fcp.rsp_validity);
  768. len +=
  769. zfcp_dbf_view(out_buf + len, "fcp_rsp_scsi_status",
  770. "0x%02x", rec->type.fcp.rsp_scsi_status);
  771. len +=
  772. zfcp_dbf_view(out_buf + len, "fcp_rsp_resid", "0x%08x",
  773. rec->type.fcp.rsp_resid);
  774. len +=
  775. zfcp_dbf_view(out_buf + len, "fcp_rsp_code", "0x%08x",
  776. rec->type.fcp.rsp_code);
  777. len +=
  778. zfcp_dbf_view(out_buf + len, "fcp_sns_info_len", "0x%08x",
  779. rec->type.fcp.sns_info_len);
  780. len +=
  781. zfcp_dbf_view_dump(out_buf + len, "fcp_sns_info",
  782. rec->type.fcp.sns_info,
  783. min((int)rec->type.fcp.sns_info_len,
  784. ZFCP_DBF_SCSI_FCP_SNS_INFO), 0,
  785. rec->type.fcp.sns_info_len);
  786. } else if (strncmp(rec->tag, "abrt", ZFCP_DBF_TAG_SIZE) == 0) {
  787. len += zfcp_dbf_view(out_buf + len, "fsf_reqid_abort", "0x%0Lx",
  788. rec->type.new_fsf_req.fsf_reqid);
  789. len += zfcp_dbf_view(out_buf + len, "fsf_seqno_abort", "0x%08x",
  790. rec->type.new_fsf_req.fsf_seqno);
  791. len += zfcp_dbf_stck(out_buf + len, "fsf_issued",
  792. rec->type.new_fsf_req.fsf_issued);
  793. } else if ((strncmp(rec->tag, "trst", ZFCP_DBF_TAG_SIZE) == 0) ||
  794. (strncmp(rec->tag, "lrst", ZFCP_DBF_TAG_SIZE) == 0)) {
  795. len += zfcp_dbf_view(out_buf + len, "fsf_reqid_reset", "0x%0Lx",
  796. rec->type.new_fsf_req.fsf_reqid);
  797. len += zfcp_dbf_view(out_buf + len, "fsf_seqno_reset", "0x%08x",
  798. rec->type.new_fsf_req.fsf_seqno);
  799. len += zfcp_dbf_stck(out_buf + len, "fsf_issued",
  800. rec->type.new_fsf_req.fsf_issued);
  801. }
  802. len += sprintf(out_buf + len, "\n");
  803. return len;
  804. }
  805. struct debug_view zfcp_scsi_dbf_view = {
  806. "structured",
  807. NULL,
  808. &zfcp_dbf_view_header,
  809. &zfcp_scsi_dbf_view_format,
  810. NULL,
  811. NULL
  812. };
  813. /**
  814. * zfcp_adapter_debug_register - registers debug feature for an adapter
  815. * @adapter: pointer to adapter for which debug features should be registered
  816. * return: -ENOMEM on error, 0 otherwise
  817. */
  818. int zfcp_adapter_debug_register(struct zfcp_adapter *adapter)
  819. {
  820. char dbf_name[DEBUG_MAX_NAME_LEN];
  821. /* debug feature area which records recovery activity */
  822. spin_lock_init(&adapter->erp_dbf_lock);
  823. sprintf(dbf_name, "zfcp_%s_erp", zfcp_get_busid_by_adapter(adapter));
  824. adapter->erp_dbf = debug_register(dbf_name, dbfsize, 2,
  825. sizeof(struct zfcp_erp_dbf_record));
  826. if (!adapter->erp_dbf)
  827. goto failed;
  828. debug_register_view(adapter->erp_dbf, &debug_hex_ascii_view);
  829. debug_set_level(adapter->erp_dbf, 3);
  830. /* debug feature area which records HBA (FSF and QDIO) conditions */
  831. spin_lock_init(&adapter->hba_dbf_lock);
  832. sprintf(dbf_name, "zfcp_%s_hba", zfcp_get_busid_by_adapter(adapter));
  833. adapter->hba_dbf = debug_register(dbf_name, dbfsize, 1,
  834. sizeof(struct zfcp_hba_dbf_record));
  835. if (!adapter->hba_dbf)
  836. goto failed;
  837. debug_register_view(adapter->hba_dbf, &debug_hex_ascii_view);
  838. debug_register_view(adapter->hba_dbf, &zfcp_hba_dbf_view);
  839. debug_set_level(adapter->hba_dbf, 3);
  840. /* debug feature area which records SAN command failures and recovery */
  841. spin_lock_init(&adapter->san_dbf_lock);
  842. sprintf(dbf_name, "zfcp_%s_san", zfcp_get_busid_by_adapter(adapter));
  843. adapter->san_dbf = debug_register(dbf_name, dbfsize, 1,
  844. sizeof(struct zfcp_san_dbf_record));
  845. if (!adapter->san_dbf)
  846. goto failed;
  847. debug_register_view(adapter->san_dbf, &debug_hex_ascii_view);
  848. debug_register_view(adapter->san_dbf, &zfcp_san_dbf_view);
  849. debug_set_level(adapter->san_dbf, 6);
  850. /* debug feature area which records SCSI command failures and recovery */
  851. spin_lock_init(&adapter->scsi_dbf_lock);
  852. sprintf(dbf_name, "zfcp_%s_scsi", zfcp_get_busid_by_adapter(adapter));
  853. adapter->scsi_dbf = debug_register(dbf_name, dbfsize, 1,
  854. sizeof(struct zfcp_scsi_dbf_record));
  855. if (!adapter->scsi_dbf)
  856. goto failed;
  857. debug_register_view(adapter->scsi_dbf, &debug_hex_ascii_view);
  858. debug_register_view(adapter->scsi_dbf, &zfcp_scsi_dbf_view);
  859. debug_set_level(adapter->scsi_dbf, 3);
  860. return 0;
  861. failed:
  862. zfcp_adapter_debug_unregister(adapter);
  863. return -ENOMEM;
  864. }
  865. /**
  866. * zfcp_adapter_debug_unregister - unregisters debug feature for an adapter
  867. * @adapter: pointer to adapter for which debug features should be unregistered
  868. */
  869. void zfcp_adapter_debug_unregister(struct zfcp_adapter *adapter)
  870. {
  871. debug_unregister(adapter->scsi_dbf);
  872. debug_unregister(adapter->san_dbf);
  873. debug_unregister(adapter->hba_dbf);
  874. debug_unregister(adapter->erp_dbf);
  875. adapter->scsi_dbf = NULL;
  876. adapter->san_dbf = NULL;
  877. adapter->hba_dbf = NULL;
  878. adapter->erp_dbf = NULL;
  879. }
  880. #undef ZFCP_LOG_AREA