PageRenderTime 51ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/release/src-rt/linux/linux-2.6/drivers/message/i2o/debug.c

https://gitlab.com/envieidoc/advancedtomato2
C | 472 lines | 408 code | 36 blank | 28 comment | 30 complexity | 257bfe4e83affd1948e5112e33588f09 MD5 | raw file
  1. #include <linux/module.h>
  2. #include <linux/kernel.h>
  3. #include <linux/pci.h>
  4. #include <linux/i2o.h>
  5. static void i2o_report_util_cmd(u8 cmd);
  6. static void i2o_report_exec_cmd(u8 cmd);
  7. static void i2o_report_fail_status(u8 req_status, u32 * msg);
  8. static void i2o_report_common_status(u8 req_status);
  9. static void i2o_report_common_dsc(u16 detailed_status);
  10. /*
  11. * Used for error reporting/debugging purposes.
  12. * Report Cmd name, Request status, Detailed Status.
  13. */
  14. void i2o_report_status(const char *severity, const char *str,
  15. struct i2o_message *m)
  16. {
  17. u32 *msg = (u32 *) m;
  18. u8 cmd = (msg[1] >> 24) & 0xFF;
  19. u8 req_status = (msg[4] >> 24) & 0xFF;
  20. u16 detailed_status = msg[4] & 0xFFFF;
  21. if (cmd == I2O_CMD_UTIL_EVT_REGISTER)
  22. return; // No status in this reply
  23. printk(KERN_DEBUG "%s%s: ", severity, str);
  24. if (cmd < 0x1F) // Utility cmd
  25. i2o_report_util_cmd(cmd);
  26. else if (cmd >= 0xA0 && cmd <= 0xEF) // Executive cmd
  27. i2o_report_exec_cmd(cmd);
  28. else
  29. printk(KERN_DEBUG "Cmd = %0#2x, ", cmd); // Other cmds
  30. if (msg[0] & MSG_FAIL) {
  31. i2o_report_fail_status(req_status, msg);
  32. return;
  33. }
  34. i2o_report_common_status(req_status);
  35. if (cmd < 0x1F || (cmd >= 0xA0 && cmd <= 0xEF))
  36. i2o_report_common_dsc(detailed_status);
  37. else
  38. printk(KERN_DEBUG " / DetailedStatus = %0#4x.\n",
  39. detailed_status);
  40. }
  41. /* Used to dump a message to syslog during debugging */
  42. void i2o_dump_message(struct i2o_message *m)
  43. {
  44. #ifdef DEBUG
  45. u32 *msg = (u32 *) m;
  46. int i;
  47. printk(KERN_INFO "Dumping I2O message size %d @ %p\n",
  48. msg[0] >> 16 & 0xffff, msg);
  49. for (i = 0; i < ((msg[0] >> 16) & 0xffff); i++)
  50. printk(KERN_INFO " msg[%d] = %0#10x\n", i, msg[i]);
  51. #endif
  52. }
  53. /*
  54. * Used for error reporting/debugging purposes.
  55. * Following fail status are common to all classes.
  56. * The preserved message must be handled in the reply handler.
  57. */
  58. static void i2o_report_fail_status(u8 req_status, u32 * msg)
  59. {
  60. static char *FAIL_STATUS[] = {
  61. "0x80", /* not used */
  62. "SERVICE_SUSPENDED", /* 0x81 */
  63. "SERVICE_TERMINATED", /* 0x82 */
  64. "CONGESTION",
  65. "FAILURE",
  66. "STATE_ERROR",
  67. "TIME_OUT",
  68. "ROUTING_FAILURE",
  69. "INVALID_VERSION",
  70. "INVALID_OFFSET",
  71. "INVALID_MSG_FLAGS",
  72. "FRAME_TOO_SMALL",
  73. "FRAME_TOO_LARGE",
  74. "INVALID_TARGET_ID",
  75. "INVALID_INITIATOR_ID",
  76. "INVALID_INITIATOR_CONTEX", /* 0x8F */
  77. "UNKNOWN_FAILURE" /* 0xFF */
  78. };
  79. if (req_status == I2O_FSC_TRANSPORT_UNKNOWN_FAILURE)
  80. printk(KERN_DEBUG "TRANSPORT_UNKNOWN_FAILURE (%0#2x).\n",
  81. req_status);
  82. else
  83. printk(KERN_DEBUG "TRANSPORT_%s.\n",
  84. FAIL_STATUS[req_status & 0x0F]);
  85. /* Dump some details */
  86. printk(KERN_ERR " InitiatorId = %d, TargetId = %d\n",
  87. (msg[1] >> 12) & 0xFFF, msg[1] & 0xFFF);
  88. printk(KERN_ERR " LowestVersion = 0x%02X, HighestVersion = 0x%02X\n",
  89. (msg[4] >> 8) & 0xFF, msg[4] & 0xFF);
  90. printk(KERN_ERR " FailingHostUnit = 0x%04X, FailingIOP = 0x%03X\n",
  91. msg[5] >> 16, msg[5] & 0xFFF);
  92. printk(KERN_ERR " Severity: 0x%02X ", (msg[4] >> 16) & 0xFF);
  93. if (msg[4] & (1 << 16))
  94. printk(KERN_DEBUG "(FormatError), "
  95. "this msg can never be delivered/processed.\n");
  96. if (msg[4] & (1 << 17))
  97. printk(KERN_DEBUG "(PathError), "
  98. "this msg can no longer be delivered/processed.\n");
  99. if (msg[4] & (1 << 18))
  100. printk(KERN_DEBUG "(PathState), "
  101. "the system state does not allow delivery.\n");
  102. if (msg[4] & (1 << 19))
  103. printk(KERN_DEBUG
  104. "(Congestion), resources temporarily not available;"
  105. "do not retry immediately.\n");
  106. }
  107. /*
  108. * Used for error reporting/debugging purposes.
  109. * Following reply status are common to all classes.
  110. */
  111. static void i2o_report_common_status(u8 req_status)
  112. {
  113. static char *REPLY_STATUS[] = {
  114. "SUCCESS",
  115. "ABORT_DIRTY",
  116. "ABORT_NO_DATA_TRANSFER",
  117. "ABORT_PARTIAL_TRANSFER",
  118. "ERROR_DIRTY",
  119. "ERROR_NO_DATA_TRANSFER",
  120. "ERROR_PARTIAL_TRANSFER",
  121. "PROCESS_ABORT_DIRTY",
  122. "PROCESS_ABORT_NO_DATA_TRANSFER",
  123. "PROCESS_ABORT_PARTIAL_TRANSFER",
  124. "TRANSACTION_ERROR",
  125. "PROGRESS_REPORT"
  126. };
  127. if (req_status >= ARRAY_SIZE(REPLY_STATUS))
  128. printk(KERN_DEBUG "RequestStatus = %0#2x", req_status);
  129. else
  130. printk(KERN_DEBUG "%s", REPLY_STATUS[req_status]);
  131. }
  132. /*
  133. * Used for error reporting/debugging purposes.
  134. * Following detailed status are valid for executive class,
  135. * utility class, DDM class and for transaction error replies.
  136. */
  137. static void i2o_report_common_dsc(u16 detailed_status)
  138. {
  139. static char *COMMON_DSC[] = {
  140. "SUCCESS",
  141. "0x01", // not used
  142. "BAD_KEY",
  143. "TCL_ERROR",
  144. "REPLY_BUFFER_FULL",
  145. "NO_SUCH_PAGE",
  146. "INSUFFICIENT_RESOURCE_SOFT",
  147. "INSUFFICIENT_RESOURCE_HARD",
  148. "0x08", // not used
  149. "CHAIN_BUFFER_TOO_LARGE",
  150. "UNSUPPORTED_FUNCTION",
  151. "DEVICE_LOCKED",
  152. "DEVICE_RESET",
  153. "INAPPROPRIATE_FUNCTION",
  154. "INVALID_INITIATOR_ADDRESS",
  155. "INVALID_MESSAGE_FLAGS",
  156. "INVALID_OFFSET",
  157. "INVALID_PARAMETER",
  158. "INVALID_REQUEST",
  159. "INVALID_TARGET_ADDRESS",
  160. "MESSAGE_TOO_LARGE",
  161. "MESSAGE_TOO_SMALL",
  162. "MISSING_PARAMETER",
  163. "TIMEOUT",
  164. "UNKNOWN_ERROR",
  165. "UNKNOWN_FUNCTION",
  166. "UNSUPPORTED_VERSION",
  167. "DEVICE_BUSY",
  168. "DEVICE_NOT_AVAILABLE"
  169. };
  170. if (detailed_status > I2O_DSC_DEVICE_NOT_AVAILABLE)
  171. printk(KERN_DEBUG " / DetailedStatus = %0#4x.\n",
  172. detailed_status);
  173. else
  174. printk(KERN_DEBUG " / %s.\n", COMMON_DSC[detailed_status]);
  175. }
  176. /*
  177. * Used for error reporting/debugging purposes
  178. */
  179. static void i2o_report_util_cmd(u8 cmd)
  180. {
  181. switch (cmd) {
  182. case I2O_CMD_UTIL_NOP:
  183. printk(KERN_DEBUG "UTIL_NOP, ");
  184. break;
  185. case I2O_CMD_UTIL_ABORT:
  186. printk(KERN_DEBUG "UTIL_ABORT, ");
  187. break;
  188. case I2O_CMD_UTIL_CLAIM:
  189. printk(KERN_DEBUG "UTIL_CLAIM, ");
  190. break;
  191. case I2O_CMD_UTIL_RELEASE:
  192. printk(KERN_DEBUG "UTIL_CLAIM_RELEASE, ");
  193. break;
  194. case I2O_CMD_UTIL_CONFIG_DIALOG:
  195. printk(KERN_DEBUG "UTIL_CONFIG_DIALOG, ");
  196. break;
  197. case I2O_CMD_UTIL_DEVICE_RESERVE:
  198. printk(KERN_DEBUG "UTIL_DEVICE_RESERVE, ");
  199. break;
  200. case I2O_CMD_UTIL_DEVICE_RELEASE:
  201. printk(KERN_DEBUG "UTIL_DEVICE_RELEASE, ");
  202. break;
  203. case I2O_CMD_UTIL_EVT_ACK:
  204. printk(KERN_DEBUG "UTIL_EVENT_ACKNOWLEDGE, ");
  205. break;
  206. case I2O_CMD_UTIL_EVT_REGISTER:
  207. printk(KERN_DEBUG "UTIL_EVENT_REGISTER, ");
  208. break;
  209. case I2O_CMD_UTIL_LOCK:
  210. printk(KERN_DEBUG "UTIL_LOCK, ");
  211. break;
  212. case I2O_CMD_UTIL_LOCK_RELEASE:
  213. printk(KERN_DEBUG "UTIL_LOCK_RELEASE, ");
  214. break;
  215. case I2O_CMD_UTIL_PARAMS_GET:
  216. printk(KERN_DEBUG "UTIL_PARAMS_GET, ");
  217. break;
  218. case I2O_CMD_UTIL_PARAMS_SET:
  219. printk(KERN_DEBUG "UTIL_PARAMS_SET, ");
  220. break;
  221. case I2O_CMD_UTIL_REPLY_FAULT_NOTIFY:
  222. printk(KERN_DEBUG "UTIL_REPLY_FAULT_NOTIFY, ");
  223. break;
  224. default:
  225. printk(KERN_DEBUG "Cmd = %0#2x, ", cmd);
  226. }
  227. }
  228. /*
  229. * Used for error reporting/debugging purposes
  230. */
  231. static void i2o_report_exec_cmd(u8 cmd)
  232. {
  233. switch (cmd) {
  234. case I2O_CMD_ADAPTER_ASSIGN:
  235. printk(KERN_DEBUG "EXEC_ADAPTER_ASSIGN, ");
  236. break;
  237. case I2O_CMD_ADAPTER_READ:
  238. printk(KERN_DEBUG "EXEC_ADAPTER_READ, ");
  239. break;
  240. case I2O_CMD_ADAPTER_RELEASE:
  241. printk(KERN_DEBUG "EXEC_ADAPTER_RELEASE, ");
  242. break;
  243. case I2O_CMD_BIOS_INFO_SET:
  244. printk(KERN_DEBUG "EXEC_BIOS_INFO_SET, ");
  245. break;
  246. case I2O_CMD_BOOT_DEVICE_SET:
  247. printk(KERN_DEBUG "EXEC_BOOT_DEVICE_SET, ");
  248. break;
  249. case I2O_CMD_CONFIG_VALIDATE:
  250. printk(KERN_DEBUG "EXEC_CONFIG_VALIDATE, ");
  251. break;
  252. case I2O_CMD_CONN_SETUP:
  253. printk(KERN_DEBUG "EXEC_CONN_SETUP, ");
  254. break;
  255. case I2O_CMD_DDM_DESTROY:
  256. printk(KERN_DEBUG "EXEC_DDM_DESTROY, ");
  257. break;
  258. case I2O_CMD_DDM_ENABLE:
  259. printk(KERN_DEBUG "EXEC_DDM_ENABLE, ");
  260. break;
  261. case I2O_CMD_DDM_QUIESCE:
  262. printk(KERN_DEBUG "EXEC_DDM_QUIESCE, ");
  263. break;
  264. case I2O_CMD_DDM_RESET:
  265. printk(KERN_DEBUG "EXEC_DDM_RESET, ");
  266. break;
  267. case I2O_CMD_DDM_SUSPEND:
  268. printk(KERN_DEBUG "EXEC_DDM_SUSPEND, ");
  269. break;
  270. case I2O_CMD_DEVICE_ASSIGN:
  271. printk(KERN_DEBUG "EXEC_DEVICE_ASSIGN, ");
  272. break;
  273. case I2O_CMD_DEVICE_RELEASE:
  274. printk(KERN_DEBUG "EXEC_DEVICE_RELEASE, ");
  275. break;
  276. case I2O_CMD_HRT_GET:
  277. printk(KERN_DEBUG "EXEC_HRT_GET, ");
  278. break;
  279. case I2O_CMD_ADAPTER_CLEAR:
  280. printk(KERN_DEBUG "EXEC_IOP_CLEAR, ");
  281. break;
  282. case I2O_CMD_ADAPTER_CONNECT:
  283. printk(KERN_DEBUG "EXEC_IOP_CONNECT, ");
  284. break;
  285. case I2O_CMD_ADAPTER_RESET:
  286. printk(KERN_DEBUG "EXEC_IOP_RESET, ");
  287. break;
  288. case I2O_CMD_LCT_NOTIFY:
  289. printk(KERN_DEBUG "EXEC_LCT_NOTIFY, ");
  290. break;
  291. case I2O_CMD_OUTBOUND_INIT:
  292. printk(KERN_DEBUG "EXEC_OUTBOUND_INIT, ");
  293. break;
  294. case I2O_CMD_PATH_ENABLE:
  295. printk(KERN_DEBUG "EXEC_PATH_ENABLE, ");
  296. break;
  297. case I2O_CMD_PATH_QUIESCE:
  298. printk(KERN_DEBUG "EXEC_PATH_QUIESCE, ");
  299. break;
  300. case I2O_CMD_PATH_RESET:
  301. printk(KERN_DEBUG "EXEC_PATH_RESET, ");
  302. break;
  303. case I2O_CMD_STATIC_MF_CREATE:
  304. printk(KERN_DEBUG "EXEC_STATIC_MF_CREATE, ");
  305. break;
  306. case I2O_CMD_STATIC_MF_RELEASE:
  307. printk(KERN_DEBUG "EXEC_STATIC_MF_RELEASE, ");
  308. break;
  309. case I2O_CMD_STATUS_GET:
  310. printk(KERN_DEBUG "EXEC_STATUS_GET, ");
  311. break;
  312. case I2O_CMD_SW_DOWNLOAD:
  313. printk(KERN_DEBUG "EXEC_SW_DOWNLOAD, ");
  314. break;
  315. case I2O_CMD_SW_UPLOAD:
  316. printk(KERN_DEBUG "EXEC_SW_UPLOAD, ");
  317. break;
  318. case I2O_CMD_SW_REMOVE:
  319. printk(KERN_DEBUG "EXEC_SW_REMOVE, ");
  320. break;
  321. case I2O_CMD_SYS_ENABLE:
  322. printk(KERN_DEBUG "EXEC_SYS_ENABLE, ");
  323. break;
  324. case I2O_CMD_SYS_MODIFY:
  325. printk(KERN_DEBUG "EXEC_SYS_MODIFY, ");
  326. break;
  327. case I2O_CMD_SYS_QUIESCE:
  328. printk(KERN_DEBUG "EXEC_SYS_QUIESCE, ");
  329. break;
  330. case I2O_CMD_SYS_TAB_SET:
  331. printk(KERN_DEBUG "EXEC_SYS_TAB_SET, ");
  332. break;
  333. default:
  334. printk(KERN_DEBUG "Cmd = %#02x, ", cmd);
  335. }
  336. }
  337. void i2o_debug_state(struct i2o_controller *c)
  338. {
  339. printk(KERN_INFO "%s: State = ", c->name);
  340. switch (((i2o_status_block *) c->status_block.virt)->iop_state) {
  341. case 0x01:
  342. printk(KERN_DEBUG "INIT\n");
  343. break;
  344. case 0x02:
  345. printk(KERN_DEBUG "RESET\n");
  346. break;
  347. case 0x04:
  348. printk(KERN_DEBUG "HOLD\n");
  349. break;
  350. case 0x05:
  351. printk(KERN_DEBUG "READY\n");
  352. break;
  353. case 0x08:
  354. printk(KERN_DEBUG "OPERATIONAL\n");
  355. break;
  356. case 0x10:
  357. printk(KERN_DEBUG "FAILED\n");
  358. break;
  359. case 0x11:
  360. printk(KERN_DEBUG "FAULTED\n");
  361. break;
  362. default:
  363. printk(KERN_DEBUG "%x (unknown !!)\n",
  364. ((i2o_status_block *) c->status_block.virt)->iop_state);
  365. }
  366. };
  367. void i2o_dump_hrt(struct i2o_controller *c)
  368. {
  369. u32 *rows = (u32 *) c->hrt.virt;
  370. u8 *p = (u8 *) c->hrt.virt;
  371. u8 *d;
  372. int count;
  373. int length;
  374. int i;
  375. int state;
  376. if (p[3] != 0) {
  377. printk(KERN_ERR
  378. "%s: HRT table for controller is too new a version.\n",
  379. c->name);
  380. return;
  381. }
  382. count = p[0] | (p[1] << 8);
  383. length = p[2];
  384. printk(KERN_INFO "%s: HRT has %d entries of %d bytes each.\n",
  385. c->name, count, length << 2);
  386. rows += 2;
  387. for (i = 0; i < count; i++) {
  388. printk(KERN_INFO "Adapter %08X: ", rows[0]);
  389. p = (u8 *) (rows + 1);
  390. d = (u8 *) (rows + 2);
  391. state = p[1] << 8 | p[0];
  392. printk("TID %04X:[", state & 0xFFF);
  393. state >>= 12;
  394. if (state & (1 << 0))
  395. printk("H"); /* Hidden */
  396. if (state & (1 << 2)) {
  397. printk("P"); /* Present */
  398. if (state & (1 << 1))
  399. printk("C"); /* Controlled */
  400. }
  401. if (state > 9)
  402. printk("*"); /* Hard */
  403. printk("]:");
  404. switch (p[3] & 0xFFFF) {
  405. case 0:
  406. /* Adapter private bus - easy */
  407. printk("Local bus %d: I/O at 0x%04X Mem 0x%08X", p[2],
  408. d[1] << 8 | d[0], *(u32 *) (d + 4));
  409. break;
  410. case 1:
  411. /* ISA bus */
  412. printk("ISA %d: CSN %d I/O at 0x%04X Mem 0x%08X", p[2],
  413. d[2], d[1] << 8 | d[0], *(u32 *) (d + 4));
  414. break;
  415. case 2: /* EISA bus */
  416. printk("EISA %d: Slot %d I/O at 0x%04X Mem 0x%08X",
  417. p[2], d[3], d[1] << 8 | d[0], *(u32 *) (d + 4));
  418. break;
  419. case 3: /* MCA bus */
  420. printk("MCA %d: Slot %d I/O at 0x%04X Mem 0x%08X", p[2],
  421. d[3], d[1] << 8 | d[0], *(u32 *) (d + 4));
  422. break;
  423. case 4: /* PCI bus */
  424. printk("PCI %d: Bus %d Device %d Function %d", p[2],
  425. d[2], d[1], d[0]);
  426. break;
  427. case 0x80: /* Other */
  428. default:
  429. printk("Unsupported bus type.");
  430. break;
  431. }
  432. printk("\n");
  433. rows += length;
  434. }
  435. }
  436. EXPORT_SYMBOL(i2o_dump_message);