PageRenderTime 29ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 2ms

/drivers/scsi/ipr.c

https://bitbucket.org/jdstroy/ipaq214
C | 7895 lines | 4946 code | 1038 blank | 1911 comment | 633 complexity | dd8555b13f6f168ae51d9a240df0c8ff MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0

Large files files are truncated, but you can click here to view the full file

  1. /*
  2. * ipr.c -- driver for IBM Power Linux RAID adapters
  3. *
  4. * Written By: Brian King <brking@us.ibm.com>, IBM Corporation
  5. *
  6. * Copyright (C) 2003, 2004 IBM Corporation
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. *
  22. */
  23. /*
  24. * Notes:
  25. *
  26. * This driver is used to control the following SCSI adapters:
  27. *
  28. * IBM iSeries: 5702, 5703, 2780, 5709, 570A, 570B
  29. *
  30. * IBM pSeries: PCI-X Dual Channel Ultra 320 SCSI RAID Adapter
  31. * PCI-X Dual Channel Ultra 320 SCSI Adapter
  32. * PCI-X Dual Channel Ultra 320 SCSI RAID Enablement Card
  33. * Embedded SCSI adapter on p615 and p655 systems
  34. *
  35. * Supported Hardware Features:
  36. * - Ultra 320 SCSI controller
  37. * - PCI-X host interface
  38. * - Embedded PowerPC RISC Processor and Hardware XOR DMA Engine
  39. * - Non-Volatile Write Cache
  40. * - Supports attachment of non-RAID disks, tape, and optical devices
  41. * - RAID Levels 0, 5, 10
  42. * - Hot spare
  43. * - Background Parity Checking
  44. * - Background Data Scrubbing
  45. * - Ability to increase the capacity of an existing RAID 5 disk array
  46. * by adding disks
  47. *
  48. * Driver Features:
  49. * - Tagged command queuing
  50. * - Adapter microcode download
  51. * - PCI hot plug
  52. * - SCSI device hot plug
  53. *
  54. */
  55. #include <linux/fs.h>
  56. #include <linux/init.h>
  57. #include <linux/types.h>
  58. #include <linux/errno.h>
  59. #include <linux/kernel.h>
  60. #include <linux/ioport.h>
  61. #include <linux/delay.h>
  62. #include <linux/pci.h>
  63. #include <linux/wait.h>
  64. #include <linux/spinlock.h>
  65. #include <linux/sched.h>
  66. #include <linux/interrupt.h>
  67. #include <linux/blkdev.h>
  68. #include <linux/firmware.h>
  69. #include <linux/module.h>
  70. #include <linux/moduleparam.h>
  71. #include <linux/libata.h>
  72. #include <linux/hdreg.h>
  73. #include <asm/io.h>
  74. #include <asm/irq.h>
  75. #include <asm/processor.h>
  76. #include <scsi/scsi.h>
  77. #include <scsi/scsi_host.h>
  78. #include <scsi/scsi_tcq.h>
  79. #include <scsi/scsi_eh.h>
  80. #include <scsi/scsi_cmnd.h>
  81. #include "ipr.h"
  82. /*
  83. * Global Data
  84. */
  85. static LIST_HEAD(ipr_ioa_head);
  86. static unsigned int ipr_log_level = IPR_DEFAULT_LOG_LEVEL;
  87. static unsigned int ipr_max_speed = 1;
  88. static int ipr_testmode = 0;
  89. static unsigned int ipr_fastfail = 0;
  90. static unsigned int ipr_transop_timeout = 0;
  91. static unsigned int ipr_enable_cache = 1;
  92. static unsigned int ipr_debug = 0;
  93. static unsigned int ipr_dual_ioa_raid = 1;
  94. static DEFINE_SPINLOCK(ipr_driver_lock);
  95. /* This table describes the differences between DMA controller chips */
  96. static const struct ipr_chip_cfg_t ipr_chip_cfg[] = {
  97. { /* Gemstone, Citrine, Obsidian, and Obsidian-E */
  98. .mailbox = 0x0042C,
  99. .cache_line_size = 0x20,
  100. {
  101. .set_interrupt_mask_reg = 0x0022C,
  102. .clr_interrupt_mask_reg = 0x00230,
  103. .sense_interrupt_mask_reg = 0x0022C,
  104. .clr_interrupt_reg = 0x00228,
  105. .sense_interrupt_reg = 0x00224,
  106. .ioarrin_reg = 0x00404,
  107. .sense_uproc_interrupt_reg = 0x00214,
  108. .set_uproc_interrupt_reg = 0x00214,
  109. .clr_uproc_interrupt_reg = 0x00218
  110. }
  111. },
  112. { /* Snipe and Scamp */
  113. .mailbox = 0x0052C,
  114. .cache_line_size = 0x20,
  115. {
  116. .set_interrupt_mask_reg = 0x00288,
  117. .clr_interrupt_mask_reg = 0x0028C,
  118. .sense_interrupt_mask_reg = 0x00288,
  119. .clr_interrupt_reg = 0x00284,
  120. .sense_interrupt_reg = 0x00280,
  121. .ioarrin_reg = 0x00504,
  122. .sense_uproc_interrupt_reg = 0x00290,
  123. .set_uproc_interrupt_reg = 0x00290,
  124. .clr_uproc_interrupt_reg = 0x00294
  125. }
  126. },
  127. };
  128. static const struct ipr_chip_t ipr_chip[] = {
  129. { PCI_VENDOR_ID_MYLEX, PCI_DEVICE_ID_IBM_GEMSTONE, &ipr_chip_cfg[0] },
  130. { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CITRINE, &ipr_chip_cfg[0] },
  131. { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN, &ipr_chip_cfg[0] },
  132. { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN, &ipr_chip_cfg[0] },
  133. { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN_E, &ipr_chip_cfg[0] },
  134. { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_SNIPE, &ipr_chip_cfg[1] },
  135. { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP, &ipr_chip_cfg[1] }
  136. };
  137. static int ipr_max_bus_speeds [] = {
  138. IPR_80MBs_SCSI_RATE, IPR_U160_SCSI_RATE, IPR_U320_SCSI_RATE
  139. };
  140. MODULE_AUTHOR("Brian King <brking@us.ibm.com>");
  141. MODULE_DESCRIPTION("IBM Power RAID SCSI Adapter Driver");
  142. module_param_named(max_speed, ipr_max_speed, uint, 0);
  143. MODULE_PARM_DESC(max_speed, "Maximum bus speed (0-2). Default: 1=U160. Speeds: 0=80 MB/s, 1=U160, 2=U320");
  144. module_param_named(log_level, ipr_log_level, uint, 0);
  145. MODULE_PARM_DESC(log_level, "Set to 0 - 4 for increasing verbosity of device driver");
  146. module_param_named(testmode, ipr_testmode, int, 0);
  147. MODULE_PARM_DESC(testmode, "DANGEROUS!!! Allows unsupported configurations");
  148. module_param_named(fastfail, ipr_fastfail, int, S_IRUGO | S_IWUSR);
  149. MODULE_PARM_DESC(fastfail, "Reduce timeouts and retries");
  150. module_param_named(transop_timeout, ipr_transop_timeout, int, 0);
  151. MODULE_PARM_DESC(transop_timeout, "Time in seconds to wait for adapter to come operational (default: 300)");
  152. module_param_named(enable_cache, ipr_enable_cache, int, 0);
  153. MODULE_PARM_DESC(enable_cache, "Enable adapter's non-volatile write cache (default: 1)");
  154. module_param_named(debug, ipr_debug, int, S_IRUGO | S_IWUSR);
  155. MODULE_PARM_DESC(debug, "Enable device driver debugging logging. Set to 1 to enable. (default: 0)");
  156. module_param_named(dual_ioa_raid, ipr_dual_ioa_raid, int, 0);
  157. MODULE_PARM_DESC(dual_ioa_raid, "Enable dual adapter RAID support. Set to 1 to enable. (default: 1)");
  158. MODULE_LICENSE("GPL");
  159. MODULE_VERSION(IPR_DRIVER_VERSION);
  160. /* A constant array of IOASCs/URCs/Error Messages */
  161. static const
  162. struct ipr_error_table_t ipr_error_table[] = {
  163. {0x00000000, 1, IPR_DEFAULT_LOG_LEVEL,
  164. "8155: An unknown error was received"},
  165. {0x00330000, 0, 0,
  166. "Soft underlength error"},
  167. {0x005A0000, 0, 0,
  168. "Command to be cancelled not found"},
  169. {0x00808000, 0, 0,
  170. "Qualified success"},
  171. {0x01080000, 1, IPR_DEFAULT_LOG_LEVEL,
  172. "FFFE: Soft device bus error recovered by the IOA"},
  173. {0x01088100, 0, IPR_DEFAULT_LOG_LEVEL,
  174. "4101: Soft device bus fabric error"},
  175. {0x01170600, 0, IPR_DEFAULT_LOG_LEVEL,
  176. "FFF9: Device sector reassign successful"},
  177. {0x01170900, 0, IPR_DEFAULT_LOG_LEVEL,
  178. "FFF7: Media error recovered by device rewrite procedures"},
  179. {0x01180200, 0, IPR_DEFAULT_LOG_LEVEL,
  180. "7001: IOA sector reassignment successful"},
  181. {0x01180500, 0, IPR_DEFAULT_LOG_LEVEL,
  182. "FFF9: Soft media error. Sector reassignment recommended"},
  183. {0x01180600, 0, IPR_DEFAULT_LOG_LEVEL,
  184. "FFF7: Media error recovered by IOA rewrite procedures"},
  185. {0x01418000, 0, IPR_DEFAULT_LOG_LEVEL,
  186. "FF3D: Soft PCI bus error recovered by the IOA"},
  187. {0x01440000, 1, IPR_DEFAULT_LOG_LEVEL,
  188. "FFF6: Device hardware error recovered by the IOA"},
  189. {0x01448100, 0, IPR_DEFAULT_LOG_LEVEL,
  190. "FFF6: Device hardware error recovered by the device"},
  191. {0x01448200, 1, IPR_DEFAULT_LOG_LEVEL,
  192. "FF3D: Soft IOA error recovered by the IOA"},
  193. {0x01448300, 0, IPR_DEFAULT_LOG_LEVEL,
  194. "FFFA: Undefined device response recovered by the IOA"},
  195. {0x014A0000, 1, IPR_DEFAULT_LOG_LEVEL,
  196. "FFF6: Device bus error, message or command phase"},
  197. {0x014A8000, 0, IPR_DEFAULT_LOG_LEVEL,
  198. "FFFE: Task Management Function failed"},
  199. {0x015D0000, 0, IPR_DEFAULT_LOG_LEVEL,
  200. "FFF6: Failure prediction threshold exceeded"},
  201. {0x015D9200, 0, IPR_DEFAULT_LOG_LEVEL,
  202. "8009: Impending cache battery pack failure"},
  203. {0x02040400, 0, 0,
  204. "34FF: Disk device format in progress"},
  205. {0x02048000, 0, IPR_DEFAULT_LOG_LEVEL,
  206. "9070: IOA requested reset"},
  207. {0x023F0000, 0, 0,
  208. "Synchronization required"},
  209. {0x024E0000, 0, 0,
  210. "No ready, IOA shutdown"},
  211. {0x025A0000, 0, 0,
  212. "Not ready, IOA has been shutdown"},
  213. {0x02670100, 0, IPR_DEFAULT_LOG_LEVEL,
  214. "3020: Storage subsystem configuration error"},
  215. {0x03110B00, 0, 0,
  216. "FFF5: Medium error, data unreadable, recommend reassign"},
  217. {0x03110C00, 0, 0,
  218. "7000: Medium error, data unreadable, do not reassign"},
  219. {0x03310000, 0, IPR_DEFAULT_LOG_LEVEL,
  220. "FFF3: Disk media format bad"},
  221. {0x04050000, 0, IPR_DEFAULT_LOG_LEVEL,
  222. "3002: Addressed device failed to respond to selection"},
  223. {0x04080000, 1, IPR_DEFAULT_LOG_LEVEL,
  224. "3100: Device bus error"},
  225. {0x04080100, 0, IPR_DEFAULT_LOG_LEVEL,
  226. "3109: IOA timed out a device command"},
  227. {0x04088000, 0, 0,
  228. "3120: SCSI bus is not operational"},
  229. {0x04088100, 0, IPR_DEFAULT_LOG_LEVEL,
  230. "4100: Hard device bus fabric error"},
  231. {0x04118000, 0, IPR_DEFAULT_LOG_LEVEL,
  232. "9000: IOA reserved area data check"},
  233. {0x04118100, 0, IPR_DEFAULT_LOG_LEVEL,
  234. "9001: IOA reserved area invalid data pattern"},
  235. {0x04118200, 0, IPR_DEFAULT_LOG_LEVEL,
  236. "9002: IOA reserved area LRC error"},
  237. {0x04320000, 0, IPR_DEFAULT_LOG_LEVEL,
  238. "102E: Out of alternate sectors for disk storage"},
  239. {0x04330000, 1, IPR_DEFAULT_LOG_LEVEL,
  240. "FFF4: Data transfer underlength error"},
  241. {0x04338000, 1, IPR_DEFAULT_LOG_LEVEL,
  242. "FFF4: Data transfer overlength error"},
  243. {0x043E0100, 0, IPR_DEFAULT_LOG_LEVEL,
  244. "3400: Logical unit failure"},
  245. {0x04408500, 0, IPR_DEFAULT_LOG_LEVEL,
  246. "FFF4: Device microcode is corrupt"},
  247. {0x04418000, 1, IPR_DEFAULT_LOG_LEVEL,
  248. "8150: PCI bus error"},
  249. {0x04430000, 1, 0,
  250. "Unsupported device bus message received"},
  251. {0x04440000, 1, IPR_DEFAULT_LOG_LEVEL,
  252. "FFF4: Disk device problem"},
  253. {0x04448200, 1, IPR_DEFAULT_LOG_LEVEL,
  254. "8150: Permanent IOA failure"},
  255. {0x04448300, 0, IPR_DEFAULT_LOG_LEVEL,
  256. "3010: Disk device returned wrong response to IOA"},
  257. {0x04448400, 0, IPR_DEFAULT_LOG_LEVEL,
  258. "8151: IOA microcode error"},
  259. {0x04448500, 0, 0,
  260. "Device bus status error"},
  261. {0x04448600, 0, IPR_DEFAULT_LOG_LEVEL,
  262. "8157: IOA error requiring IOA reset to recover"},
  263. {0x04448700, 0, 0,
  264. "ATA device status error"},
  265. {0x04490000, 0, 0,
  266. "Message reject received from the device"},
  267. {0x04449200, 0, IPR_DEFAULT_LOG_LEVEL,
  268. "8008: A permanent cache battery pack failure occurred"},
  269. {0x0444A000, 0, IPR_DEFAULT_LOG_LEVEL,
  270. "9090: Disk unit has been modified after the last known status"},
  271. {0x0444A200, 0, IPR_DEFAULT_LOG_LEVEL,
  272. "9081: IOA detected device error"},
  273. {0x0444A300, 0, IPR_DEFAULT_LOG_LEVEL,
  274. "9082: IOA detected device error"},
  275. {0x044A0000, 1, IPR_DEFAULT_LOG_LEVEL,
  276. "3110: Device bus error, message or command phase"},
  277. {0x044A8000, 1, IPR_DEFAULT_LOG_LEVEL,
  278. "3110: SAS Command / Task Management Function failed"},
  279. {0x04670400, 0, IPR_DEFAULT_LOG_LEVEL,
  280. "9091: Incorrect hardware configuration change has been detected"},
  281. {0x04678000, 0, IPR_DEFAULT_LOG_LEVEL,
  282. "9073: Invalid multi-adapter configuration"},
  283. {0x04678100, 0, IPR_DEFAULT_LOG_LEVEL,
  284. "4010: Incorrect connection between cascaded expanders"},
  285. {0x04678200, 0, IPR_DEFAULT_LOG_LEVEL,
  286. "4020: Connections exceed IOA design limits"},
  287. {0x04678300, 0, IPR_DEFAULT_LOG_LEVEL,
  288. "4030: Incorrect multipath connection"},
  289. {0x04679000, 0, IPR_DEFAULT_LOG_LEVEL,
  290. "4110: Unsupported enclosure function"},
  291. {0x046E0000, 0, IPR_DEFAULT_LOG_LEVEL,
  292. "FFF4: Command to logical unit failed"},
  293. {0x05240000, 1, 0,
  294. "Illegal request, invalid request type or request packet"},
  295. {0x05250000, 0, 0,
  296. "Illegal request, invalid resource handle"},
  297. {0x05258000, 0, 0,
  298. "Illegal request, commands not allowed to this device"},
  299. {0x05258100, 0, 0,
  300. "Illegal request, command not allowed to a secondary adapter"},
  301. {0x05260000, 0, 0,
  302. "Illegal request, invalid field in parameter list"},
  303. {0x05260100, 0, 0,
  304. "Illegal request, parameter not supported"},
  305. {0x05260200, 0, 0,
  306. "Illegal request, parameter value invalid"},
  307. {0x052C0000, 0, 0,
  308. "Illegal request, command sequence error"},
  309. {0x052C8000, 1, 0,
  310. "Illegal request, dual adapter support not enabled"},
  311. {0x06040500, 0, IPR_DEFAULT_LOG_LEVEL,
  312. "9031: Array protection temporarily suspended, protection resuming"},
  313. {0x06040600, 0, IPR_DEFAULT_LOG_LEVEL,
  314. "9040: Array protection temporarily suspended, protection resuming"},
  315. {0x06288000, 0, IPR_DEFAULT_LOG_LEVEL,
  316. "3140: Device bus not ready to ready transition"},
  317. {0x06290000, 0, IPR_DEFAULT_LOG_LEVEL,
  318. "FFFB: SCSI bus was reset"},
  319. {0x06290500, 0, 0,
  320. "FFFE: SCSI bus transition to single ended"},
  321. {0x06290600, 0, 0,
  322. "FFFE: SCSI bus transition to LVD"},
  323. {0x06298000, 0, IPR_DEFAULT_LOG_LEVEL,
  324. "FFFB: SCSI bus was reset by another initiator"},
  325. {0x063F0300, 0, IPR_DEFAULT_LOG_LEVEL,
  326. "3029: A device replacement has occurred"},
  327. {0x064C8000, 0, IPR_DEFAULT_LOG_LEVEL,
  328. "9051: IOA cache data exists for a missing or failed device"},
  329. {0x064C8100, 0, IPR_DEFAULT_LOG_LEVEL,
  330. "9055: Auxiliary cache IOA contains cache data needed by the primary IOA"},
  331. {0x06670100, 0, IPR_DEFAULT_LOG_LEVEL,
  332. "9025: Disk unit is not supported at its physical location"},
  333. {0x06670600, 0, IPR_DEFAULT_LOG_LEVEL,
  334. "3020: IOA detected a SCSI bus configuration error"},
  335. {0x06678000, 0, IPR_DEFAULT_LOG_LEVEL,
  336. "3150: SCSI bus configuration error"},
  337. {0x06678100, 0, IPR_DEFAULT_LOG_LEVEL,
  338. "9074: Asymmetric advanced function disk configuration"},
  339. {0x06678300, 0, IPR_DEFAULT_LOG_LEVEL,
  340. "4040: Incomplete multipath connection between IOA and enclosure"},
  341. {0x06678400, 0, IPR_DEFAULT_LOG_LEVEL,
  342. "4041: Incomplete multipath connection between enclosure and device"},
  343. {0x06678500, 0, IPR_DEFAULT_LOG_LEVEL,
  344. "9075: Incomplete multipath connection between IOA and remote IOA"},
  345. {0x06678600, 0, IPR_DEFAULT_LOG_LEVEL,
  346. "9076: Configuration error, missing remote IOA"},
  347. {0x06679100, 0, IPR_DEFAULT_LOG_LEVEL,
  348. "4050: Enclosure does not support a required multipath function"},
  349. {0x06690000, 0, IPR_DEFAULT_LOG_LEVEL,
  350. "4070: Logically bad block written on device"},
  351. {0x06690200, 0, IPR_DEFAULT_LOG_LEVEL,
  352. "9041: Array protection temporarily suspended"},
  353. {0x06698200, 0, IPR_DEFAULT_LOG_LEVEL,
  354. "9042: Corrupt array parity detected on specified device"},
  355. {0x066B0200, 0, IPR_DEFAULT_LOG_LEVEL,
  356. "9030: Array no longer protected due to missing or failed disk unit"},
  357. {0x066B8000, 0, IPR_DEFAULT_LOG_LEVEL,
  358. "9071: Link operational transition"},
  359. {0x066B8100, 0, IPR_DEFAULT_LOG_LEVEL,
  360. "9072: Link not operational transition"},
  361. {0x066B8200, 0, IPR_DEFAULT_LOG_LEVEL,
  362. "9032: Array exposed but still protected"},
  363. {0x066B8300, 0, IPR_DEFAULT_LOG_LEVEL + 1,
  364. "70DD: Device forced failed by disrupt device command"},
  365. {0x066B9100, 0, IPR_DEFAULT_LOG_LEVEL,
  366. "4061: Multipath redundancy level got better"},
  367. {0x066B9200, 0, IPR_DEFAULT_LOG_LEVEL,
  368. "4060: Multipath redundancy level got worse"},
  369. {0x07270000, 0, 0,
  370. "Failure due to other device"},
  371. {0x07278000, 0, IPR_DEFAULT_LOG_LEVEL,
  372. "9008: IOA does not support functions expected by devices"},
  373. {0x07278100, 0, IPR_DEFAULT_LOG_LEVEL,
  374. "9010: Cache data associated with attached devices cannot be found"},
  375. {0x07278200, 0, IPR_DEFAULT_LOG_LEVEL,
  376. "9011: Cache data belongs to devices other than those attached"},
  377. {0x07278400, 0, IPR_DEFAULT_LOG_LEVEL,
  378. "9020: Array missing 2 or more devices with only 1 device present"},
  379. {0x07278500, 0, IPR_DEFAULT_LOG_LEVEL,
  380. "9021: Array missing 2 or more devices with 2 or more devices present"},
  381. {0x07278600, 0, IPR_DEFAULT_LOG_LEVEL,
  382. "9022: Exposed array is missing a required device"},
  383. {0x07278700, 0, IPR_DEFAULT_LOG_LEVEL,
  384. "9023: Array member(s) not at required physical locations"},
  385. {0x07278800, 0, IPR_DEFAULT_LOG_LEVEL,
  386. "9024: Array not functional due to present hardware configuration"},
  387. {0x07278900, 0, IPR_DEFAULT_LOG_LEVEL,
  388. "9026: Array not functional due to present hardware configuration"},
  389. {0x07278A00, 0, IPR_DEFAULT_LOG_LEVEL,
  390. "9027: Array is missing a device and parity is out of sync"},
  391. {0x07278B00, 0, IPR_DEFAULT_LOG_LEVEL,
  392. "9028: Maximum number of arrays already exist"},
  393. {0x07278C00, 0, IPR_DEFAULT_LOG_LEVEL,
  394. "9050: Required cache data cannot be located for a disk unit"},
  395. {0x07278D00, 0, IPR_DEFAULT_LOG_LEVEL,
  396. "9052: Cache data exists for a device that has been modified"},
  397. {0x07278F00, 0, IPR_DEFAULT_LOG_LEVEL,
  398. "9054: IOA resources not available due to previous problems"},
  399. {0x07279100, 0, IPR_DEFAULT_LOG_LEVEL,
  400. "9092: Disk unit requires initialization before use"},
  401. {0x07279200, 0, IPR_DEFAULT_LOG_LEVEL,
  402. "9029: Incorrect hardware configuration change has been detected"},
  403. {0x07279600, 0, IPR_DEFAULT_LOG_LEVEL,
  404. "9060: One or more disk pairs are missing from an array"},
  405. {0x07279700, 0, IPR_DEFAULT_LOG_LEVEL,
  406. "9061: One or more disks are missing from an array"},
  407. {0x07279800, 0, IPR_DEFAULT_LOG_LEVEL,
  408. "9062: One or more disks are missing from an array"},
  409. {0x07279900, 0, IPR_DEFAULT_LOG_LEVEL,
  410. "9063: Maximum number of functional arrays has been exceeded"},
  411. {0x0B260000, 0, 0,
  412. "Aborted command, invalid descriptor"},
  413. {0x0B5A0000, 0, 0,
  414. "Command terminated by host"}
  415. };
  416. static const struct ipr_ses_table_entry ipr_ses_table[] = {
  417. { "2104-DL1 ", "XXXXXXXXXXXXXXXX", 80 },
  418. { "2104-TL1 ", "XXXXXXXXXXXXXXXX", 80 },
  419. { "HSBP07M P U2SCSI", "XXXXXXXXXXXXXXXX", 80 }, /* Hidive 7 slot */
  420. { "HSBP05M P U2SCSI", "XXXXXXXXXXXXXXXX", 80 }, /* Hidive 5 slot */
  421. { "HSBP05M S U2SCSI", "XXXXXXXXXXXXXXXX", 80 }, /* Bowtie */
  422. { "HSBP06E ASU2SCSI", "XXXXXXXXXXXXXXXX", 80 }, /* MartinFenning */
  423. { "2104-DU3 ", "XXXXXXXXXXXXXXXX", 160 },
  424. { "2104-TU3 ", "XXXXXXXXXXXXXXXX", 160 },
  425. { "HSBP04C RSU2SCSI", "XXXXXXX*XXXXXXXX", 160 },
  426. { "HSBP06E RSU2SCSI", "XXXXXXX*XXXXXXXX", 160 },
  427. { "St V1S2 ", "XXXXXXXXXXXXXXXX", 160 },
  428. { "HSBPD4M PU3SCSI", "XXXXXXX*XXXXXXXX", 160 },
  429. { "VSBPD1H U3SCSI", "XXXXXXX*XXXXXXXX", 160 }
  430. };
  431. /*
  432. * Function Prototypes
  433. */
  434. static int ipr_reset_alert(struct ipr_cmnd *);
  435. static void ipr_process_ccn(struct ipr_cmnd *);
  436. static void ipr_process_error(struct ipr_cmnd *);
  437. static void ipr_reset_ioa_job(struct ipr_cmnd *);
  438. static void ipr_initiate_ioa_reset(struct ipr_ioa_cfg *,
  439. enum ipr_shutdown_type);
  440. #ifdef CONFIG_SCSI_IPR_TRACE
  441. /**
  442. * ipr_trc_hook - Add a trace entry to the driver trace
  443. * @ipr_cmd: ipr command struct
  444. * @type: trace type
  445. * @add_data: additional data
  446. *
  447. * Return value:
  448. * none
  449. **/
  450. static void ipr_trc_hook(struct ipr_cmnd *ipr_cmd,
  451. u8 type, u32 add_data)
  452. {
  453. struct ipr_trace_entry *trace_entry;
  454. struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg;
  455. trace_entry = &ioa_cfg->trace[ioa_cfg->trace_index++];
  456. trace_entry->time = jiffies;
  457. trace_entry->op_code = ipr_cmd->ioarcb.cmd_pkt.cdb[0];
  458. trace_entry->type = type;
  459. trace_entry->ata_op_code = ipr_cmd->ioarcb.add_data.u.regs.command;
  460. trace_entry->cmd_index = ipr_cmd->cmd_index & 0xff;
  461. trace_entry->res_handle = ipr_cmd->ioarcb.res_handle;
  462. trace_entry->u.add_data = add_data;
  463. }
  464. #else
  465. #define ipr_trc_hook(ipr_cmd, type, add_data) do { } while(0)
  466. #endif
  467. /**
  468. * ipr_reinit_ipr_cmnd - Re-initialize an IPR Cmnd block for reuse
  469. * @ipr_cmd: ipr command struct
  470. *
  471. * Return value:
  472. * none
  473. **/
  474. static void ipr_reinit_ipr_cmnd(struct ipr_cmnd *ipr_cmd)
  475. {
  476. struct ipr_ioarcb *ioarcb = &ipr_cmd->ioarcb;
  477. struct ipr_ioasa *ioasa = &ipr_cmd->ioasa;
  478. dma_addr_t dma_addr = be32_to_cpu(ioarcb->ioarcb_host_pci_addr);
  479. memset(&ioarcb->cmd_pkt, 0, sizeof(struct ipr_cmd_pkt));
  480. ioarcb->write_data_transfer_length = 0;
  481. ioarcb->read_data_transfer_length = 0;
  482. ioarcb->write_ioadl_len = 0;
  483. ioarcb->read_ioadl_len = 0;
  484. ioarcb->write_ioadl_addr =
  485. cpu_to_be32(dma_addr + offsetof(struct ipr_cmnd, ioadl));
  486. ioarcb->read_ioadl_addr = ioarcb->write_ioadl_addr;
  487. ioasa->ioasc = 0;
  488. ioasa->residual_data_len = 0;
  489. ioasa->u.gata.status = 0;
  490. ipr_cmd->scsi_cmd = NULL;
  491. ipr_cmd->qc = NULL;
  492. ipr_cmd->sense_buffer[0] = 0;
  493. ipr_cmd->dma_use_sg = 0;
  494. }
  495. /**
  496. * ipr_init_ipr_cmnd - Initialize an IPR Cmnd block
  497. * @ipr_cmd: ipr command struct
  498. *
  499. * Return value:
  500. * none
  501. **/
  502. static void ipr_init_ipr_cmnd(struct ipr_cmnd *ipr_cmd)
  503. {
  504. ipr_reinit_ipr_cmnd(ipr_cmd);
  505. ipr_cmd->u.scratch = 0;
  506. ipr_cmd->sibling = NULL;
  507. init_timer(&ipr_cmd->timer);
  508. }
  509. /**
  510. * ipr_get_free_ipr_cmnd - Get a free IPR Cmnd block
  511. * @ioa_cfg: ioa config struct
  512. *
  513. * Return value:
  514. * pointer to ipr command struct
  515. **/
  516. static
  517. struct ipr_cmnd *ipr_get_free_ipr_cmnd(struct ipr_ioa_cfg *ioa_cfg)
  518. {
  519. struct ipr_cmnd *ipr_cmd;
  520. ipr_cmd = list_entry(ioa_cfg->free_q.next, struct ipr_cmnd, queue);
  521. list_del(&ipr_cmd->queue);
  522. ipr_init_ipr_cmnd(ipr_cmd);
  523. return ipr_cmd;
  524. }
  525. /**
  526. * ipr_mask_and_clear_interrupts - Mask all and clear specified interrupts
  527. * @ioa_cfg: ioa config struct
  528. * @clr_ints: interrupts to clear
  529. *
  530. * This function masks all interrupts on the adapter, then clears the
  531. * interrupts specified in the mask
  532. *
  533. * Return value:
  534. * none
  535. **/
  536. static void ipr_mask_and_clear_interrupts(struct ipr_ioa_cfg *ioa_cfg,
  537. u32 clr_ints)
  538. {
  539. volatile u32 int_reg;
  540. /* Stop new interrupts */
  541. ioa_cfg->allow_interrupts = 0;
  542. /* Set interrupt mask to stop all new interrupts */
  543. writel(~0, ioa_cfg->regs.set_interrupt_mask_reg);
  544. /* Clear any pending interrupts */
  545. writel(clr_ints, ioa_cfg->regs.clr_interrupt_reg);
  546. int_reg = readl(ioa_cfg->regs.sense_interrupt_reg);
  547. }
  548. /**
  549. * ipr_save_pcix_cmd_reg - Save PCI-X command register
  550. * @ioa_cfg: ioa config struct
  551. *
  552. * Return value:
  553. * 0 on success / -EIO on failure
  554. **/
  555. static int ipr_save_pcix_cmd_reg(struct ipr_ioa_cfg *ioa_cfg)
  556. {
  557. int pcix_cmd_reg = pci_find_capability(ioa_cfg->pdev, PCI_CAP_ID_PCIX);
  558. if (pcix_cmd_reg == 0)
  559. return 0;
  560. if (pci_read_config_word(ioa_cfg->pdev, pcix_cmd_reg + PCI_X_CMD,
  561. &ioa_cfg->saved_pcix_cmd_reg) != PCIBIOS_SUCCESSFUL) {
  562. dev_err(&ioa_cfg->pdev->dev, "Failed to save PCI-X command register\n");
  563. return -EIO;
  564. }
  565. ioa_cfg->saved_pcix_cmd_reg |= PCI_X_CMD_DPERR_E | PCI_X_CMD_ERO;
  566. return 0;
  567. }
  568. /**
  569. * ipr_set_pcix_cmd_reg - Setup PCI-X command register
  570. * @ioa_cfg: ioa config struct
  571. *
  572. * Return value:
  573. * 0 on success / -EIO on failure
  574. **/
  575. static int ipr_set_pcix_cmd_reg(struct ipr_ioa_cfg *ioa_cfg)
  576. {
  577. int pcix_cmd_reg = pci_find_capability(ioa_cfg->pdev, PCI_CAP_ID_PCIX);
  578. if (pcix_cmd_reg) {
  579. if (pci_write_config_word(ioa_cfg->pdev, pcix_cmd_reg + PCI_X_CMD,
  580. ioa_cfg->saved_pcix_cmd_reg) != PCIBIOS_SUCCESSFUL) {
  581. dev_err(&ioa_cfg->pdev->dev, "Failed to setup PCI-X command register\n");
  582. return -EIO;
  583. }
  584. }
  585. return 0;
  586. }
  587. /**
  588. * ipr_sata_eh_done - done function for aborted SATA commands
  589. * @ipr_cmd: ipr command struct
  590. *
  591. * This function is invoked for ops generated to SATA
  592. * devices which are being aborted.
  593. *
  594. * Return value:
  595. * none
  596. **/
  597. static void ipr_sata_eh_done(struct ipr_cmnd *ipr_cmd)
  598. {
  599. struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg;
  600. struct ata_queued_cmd *qc = ipr_cmd->qc;
  601. struct ipr_sata_port *sata_port = qc->ap->private_data;
  602. qc->err_mask |= AC_ERR_OTHER;
  603. sata_port->ioasa.status |= ATA_BUSY;
  604. list_add_tail(&ipr_cmd->queue, &ioa_cfg->free_q);
  605. ata_qc_complete(qc);
  606. }
  607. /**
  608. * ipr_scsi_eh_done - mid-layer done function for aborted ops
  609. * @ipr_cmd: ipr command struct
  610. *
  611. * This function is invoked by the interrupt handler for
  612. * ops generated by the SCSI mid-layer which are being aborted.
  613. *
  614. * Return value:
  615. * none
  616. **/
  617. static void ipr_scsi_eh_done(struct ipr_cmnd *ipr_cmd)
  618. {
  619. struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg;
  620. struct scsi_cmnd *scsi_cmd = ipr_cmd->scsi_cmd;
  621. scsi_cmd->result |= (DID_ERROR << 16);
  622. scsi_dma_unmap(ipr_cmd->scsi_cmd);
  623. scsi_cmd->scsi_done(scsi_cmd);
  624. list_add_tail(&ipr_cmd->queue, &ioa_cfg->free_q);
  625. }
  626. /**
  627. * ipr_fail_all_ops - Fails all outstanding ops.
  628. * @ioa_cfg: ioa config struct
  629. *
  630. * This function fails all outstanding ops.
  631. *
  632. * Return value:
  633. * none
  634. **/
  635. static void ipr_fail_all_ops(struct ipr_ioa_cfg *ioa_cfg)
  636. {
  637. struct ipr_cmnd *ipr_cmd, *temp;
  638. ENTER;
  639. list_for_each_entry_safe(ipr_cmd, temp, &ioa_cfg->pending_q, queue) {
  640. list_del(&ipr_cmd->queue);
  641. ipr_cmd->ioasa.ioasc = cpu_to_be32(IPR_IOASC_IOA_WAS_RESET);
  642. ipr_cmd->ioasa.ilid = cpu_to_be32(IPR_DRIVER_ILID);
  643. if (ipr_cmd->scsi_cmd)
  644. ipr_cmd->done = ipr_scsi_eh_done;
  645. else if (ipr_cmd->qc)
  646. ipr_cmd->done = ipr_sata_eh_done;
  647. ipr_trc_hook(ipr_cmd, IPR_TRACE_FINISH, IPR_IOASC_IOA_WAS_RESET);
  648. del_timer(&ipr_cmd->timer);
  649. ipr_cmd->done(ipr_cmd);
  650. }
  651. LEAVE;
  652. }
  653. /**
  654. * ipr_do_req - Send driver initiated requests.
  655. * @ipr_cmd: ipr command struct
  656. * @done: done function
  657. * @timeout_func: timeout function
  658. * @timeout: timeout value
  659. *
  660. * This function sends the specified command to the adapter with the
  661. * timeout given. The done function is invoked on command completion.
  662. *
  663. * Return value:
  664. * none
  665. **/
  666. static void ipr_do_req(struct ipr_cmnd *ipr_cmd,
  667. void (*done) (struct ipr_cmnd *),
  668. void (*timeout_func) (struct ipr_cmnd *), u32 timeout)
  669. {
  670. struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg;
  671. list_add_tail(&ipr_cmd->queue, &ioa_cfg->pending_q);
  672. ipr_cmd->done = done;
  673. ipr_cmd->timer.data = (unsigned long) ipr_cmd;
  674. ipr_cmd->timer.expires = jiffies + timeout;
  675. ipr_cmd->timer.function = (void (*)(unsigned long))timeout_func;
  676. add_timer(&ipr_cmd->timer);
  677. ipr_trc_hook(ipr_cmd, IPR_TRACE_START, 0);
  678. mb();
  679. writel(be32_to_cpu(ipr_cmd->ioarcb.ioarcb_host_pci_addr),
  680. ioa_cfg->regs.ioarrin_reg);
  681. }
  682. /**
  683. * ipr_internal_cmd_done - Op done function for an internally generated op.
  684. * @ipr_cmd: ipr command struct
  685. *
  686. * This function is the op done function for an internally generated,
  687. * blocking op. It simply wakes the sleeping thread.
  688. *
  689. * Return value:
  690. * none
  691. **/
  692. static void ipr_internal_cmd_done(struct ipr_cmnd *ipr_cmd)
  693. {
  694. if (ipr_cmd->sibling)
  695. ipr_cmd->sibling = NULL;
  696. else
  697. complete(&ipr_cmd->completion);
  698. }
  699. /**
  700. * ipr_send_blocking_cmd - Send command and sleep on its completion.
  701. * @ipr_cmd: ipr command struct
  702. * @timeout_func: function to invoke if command times out
  703. * @timeout: timeout
  704. *
  705. * Return value:
  706. * none
  707. **/
  708. static void ipr_send_blocking_cmd(struct ipr_cmnd *ipr_cmd,
  709. void (*timeout_func) (struct ipr_cmnd *ipr_cmd),
  710. u32 timeout)
  711. {
  712. struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg;
  713. init_completion(&ipr_cmd->completion);
  714. ipr_do_req(ipr_cmd, ipr_internal_cmd_done, timeout_func, timeout);
  715. spin_unlock_irq(ioa_cfg->host->host_lock);
  716. wait_for_completion(&ipr_cmd->completion);
  717. spin_lock_irq(ioa_cfg->host->host_lock);
  718. }
  719. /**
  720. * ipr_send_hcam - Send an HCAM to the adapter.
  721. * @ioa_cfg: ioa config struct
  722. * @type: HCAM type
  723. * @hostrcb: hostrcb struct
  724. *
  725. * This function will send a Host Controlled Async command to the adapter.
  726. * If HCAMs are currently not allowed to be issued to the adapter, it will
  727. * place the hostrcb on the free queue.
  728. *
  729. * Return value:
  730. * none
  731. **/
  732. static void ipr_send_hcam(struct ipr_ioa_cfg *ioa_cfg, u8 type,
  733. struct ipr_hostrcb *hostrcb)
  734. {
  735. struct ipr_cmnd *ipr_cmd;
  736. struct ipr_ioarcb *ioarcb;
  737. if (ioa_cfg->allow_cmds) {
  738. ipr_cmd = ipr_get_free_ipr_cmnd(ioa_cfg);
  739. list_add_tail(&ipr_cmd->queue, &ioa_cfg->pending_q);
  740. list_add_tail(&hostrcb->queue, &ioa_cfg->hostrcb_pending_q);
  741. ipr_cmd->u.hostrcb = hostrcb;
  742. ioarcb = &ipr_cmd->ioarcb;
  743. ioarcb->res_handle = cpu_to_be32(IPR_IOA_RES_HANDLE);
  744. ioarcb->cmd_pkt.request_type = IPR_RQTYPE_HCAM;
  745. ioarcb->cmd_pkt.cdb[0] = IPR_HOST_CONTROLLED_ASYNC;
  746. ioarcb->cmd_pkt.cdb[1] = type;
  747. ioarcb->cmd_pkt.cdb[7] = (sizeof(hostrcb->hcam) >> 8) & 0xff;
  748. ioarcb->cmd_pkt.cdb[8] = sizeof(hostrcb->hcam) & 0xff;
  749. ioarcb->read_data_transfer_length = cpu_to_be32(sizeof(hostrcb->hcam));
  750. ioarcb->read_ioadl_len = cpu_to_be32(sizeof(struct ipr_ioadl_desc));
  751. ipr_cmd->ioadl[0].flags_and_data_len =
  752. cpu_to_be32(IPR_IOADL_FLAGS_READ_LAST | sizeof(hostrcb->hcam));
  753. ipr_cmd->ioadl[0].address = cpu_to_be32(hostrcb->hostrcb_dma);
  754. if (type == IPR_HCAM_CDB_OP_CODE_CONFIG_CHANGE)
  755. ipr_cmd->done = ipr_process_ccn;
  756. else
  757. ipr_cmd->done = ipr_process_error;
  758. ipr_trc_hook(ipr_cmd, IPR_TRACE_START, IPR_IOA_RES_ADDR);
  759. mb();
  760. writel(be32_to_cpu(ipr_cmd->ioarcb.ioarcb_host_pci_addr),
  761. ioa_cfg->regs.ioarrin_reg);
  762. } else {
  763. list_add_tail(&hostrcb->queue, &ioa_cfg->hostrcb_free_q);
  764. }
  765. }
  766. /**
  767. * ipr_init_res_entry - Initialize a resource entry struct.
  768. * @res: resource entry struct
  769. *
  770. * Return value:
  771. * none
  772. **/
  773. static void ipr_init_res_entry(struct ipr_resource_entry *res)
  774. {
  775. res->needs_sync_complete = 0;
  776. res->in_erp = 0;
  777. res->add_to_ml = 0;
  778. res->del_from_ml = 0;
  779. res->resetting_device = 0;
  780. res->sdev = NULL;
  781. res->sata_port = NULL;
  782. }
  783. /**
  784. * ipr_handle_config_change - Handle a config change from the adapter
  785. * @ioa_cfg: ioa config struct
  786. * @hostrcb: hostrcb
  787. *
  788. * Return value:
  789. * none
  790. **/
  791. static void ipr_handle_config_change(struct ipr_ioa_cfg *ioa_cfg,
  792. struct ipr_hostrcb *hostrcb)
  793. {
  794. struct ipr_resource_entry *res = NULL;
  795. struct ipr_config_table_entry *cfgte;
  796. u32 is_ndn = 1;
  797. cfgte = &hostrcb->hcam.u.ccn.cfgte;
  798. list_for_each_entry(res, &ioa_cfg->used_res_q, queue) {
  799. if (!memcmp(&res->cfgte.res_addr, &cfgte->res_addr,
  800. sizeof(cfgte->res_addr))) {
  801. is_ndn = 0;
  802. break;
  803. }
  804. }
  805. if (is_ndn) {
  806. if (list_empty(&ioa_cfg->free_res_q)) {
  807. ipr_send_hcam(ioa_cfg,
  808. IPR_HCAM_CDB_OP_CODE_CONFIG_CHANGE,
  809. hostrcb);
  810. return;
  811. }
  812. res = list_entry(ioa_cfg->free_res_q.next,
  813. struct ipr_resource_entry, queue);
  814. list_del(&res->queue);
  815. ipr_init_res_entry(res);
  816. list_add_tail(&res->queue, &ioa_cfg->used_res_q);
  817. }
  818. memcpy(&res->cfgte, cfgte, sizeof(struct ipr_config_table_entry));
  819. if (hostrcb->hcam.notify_type == IPR_HOST_RCB_NOTIF_TYPE_REM_ENTRY) {
  820. if (res->sdev) {
  821. res->del_from_ml = 1;
  822. res->cfgte.res_handle = IPR_INVALID_RES_HANDLE;
  823. if (ioa_cfg->allow_ml_add_del)
  824. schedule_work(&ioa_cfg->work_q);
  825. } else
  826. list_move_tail(&res->queue, &ioa_cfg->free_res_q);
  827. } else if (!res->sdev) {
  828. res->add_to_ml = 1;
  829. if (ioa_cfg->allow_ml_add_del)
  830. schedule_work(&ioa_cfg->work_q);
  831. }
  832. ipr_send_hcam(ioa_cfg, IPR_HCAM_CDB_OP_CODE_CONFIG_CHANGE, hostrcb);
  833. }
  834. /**
  835. * ipr_process_ccn - Op done function for a CCN.
  836. * @ipr_cmd: ipr command struct
  837. *
  838. * This function is the op done function for a configuration
  839. * change notification host controlled async from the adapter.
  840. *
  841. * Return value:
  842. * none
  843. **/
  844. static void ipr_process_ccn(struct ipr_cmnd *ipr_cmd)
  845. {
  846. struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg;
  847. struct ipr_hostrcb *hostrcb = ipr_cmd->u.hostrcb;
  848. u32 ioasc = be32_to_cpu(ipr_cmd->ioasa.ioasc);
  849. list_del(&hostrcb->queue);
  850. list_add_tail(&ipr_cmd->queue, &ioa_cfg->free_q);
  851. if (ioasc) {
  852. if (ioasc != IPR_IOASC_IOA_WAS_RESET)
  853. dev_err(&ioa_cfg->pdev->dev,
  854. "Host RCB failed with IOASC: 0x%08X\n", ioasc);
  855. ipr_send_hcam(ioa_cfg, IPR_HCAM_CDB_OP_CODE_CONFIG_CHANGE, hostrcb);
  856. } else {
  857. ipr_handle_config_change(ioa_cfg, hostrcb);
  858. }
  859. }
  860. /**
  861. * strip_and_pad_whitespace - Strip and pad trailing whitespace.
  862. * @i: index into buffer
  863. * @buf: string to modify
  864. *
  865. * This function will strip all trailing whitespace, pad the end
  866. * of the string with a single space, and NULL terminate the string.
  867. *
  868. * Return value:
  869. * new length of string
  870. **/
  871. static int strip_and_pad_whitespace(int i, char *buf)
  872. {
  873. while (i && buf[i] == ' ')
  874. i--;
  875. buf[i+1] = ' ';
  876. buf[i+2] = '\0';
  877. return i + 2;
  878. }
  879. /**
  880. * ipr_log_vpd_compact - Log the passed extended VPD compactly.
  881. * @prefix: string to print at start of printk
  882. * @hostrcb: hostrcb pointer
  883. * @vpd: vendor/product id/sn struct
  884. *
  885. * Return value:
  886. * none
  887. **/
  888. static void ipr_log_vpd_compact(char *prefix, struct ipr_hostrcb *hostrcb,
  889. struct ipr_vpd *vpd)
  890. {
  891. char buffer[IPR_VENDOR_ID_LEN + IPR_PROD_ID_LEN + IPR_SERIAL_NUM_LEN + 3];
  892. int i = 0;
  893. memcpy(buffer, vpd->vpids.vendor_id, IPR_VENDOR_ID_LEN);
  894. i = strip_and_pad_whitespace(IPR_VENDOR_ID_LEN - 1, buffer);
  895. memcpy(&buffer[i], vpd->vpids.product_id, IPR_PROD_ID_LEN);
  896. i = strip_and_pad_whitespace(i + IPR_PROD_ID_LEN - 1, buffer);
  897. memcpy(&buffer[i], vpd->sn, IPR_SERIAL_NUM_LEN);
  898. buffer[IPR_SERIAL_NUM_LEN + i] = '\0';
  899. ipr_hcam_err(hostrcb, "%s VPID/SN: %s\n", prefix, buffer);
  900. }
  901. /**
  902. * ipr_log_vpd - Log the passed VPD to the error log.
  903. * @vpd: vendor/product id/sn struct
  904. *
  905. * Return value:
  906. * none
  907. **/
  908. static void ipr_log_vpd(struct ipr_vpd *vpd)
  909. {
  910. char buffer[IPR_VENDOR_ID_LEN + IPR_PROD_ID_LEN
  911. + IPR_SERIAL_NUM_LEN];
  912. memcpy(buffer, vpd->vpids.vendor_id, IPR_VENDOR_ID_LEN);
  913. memcpy(buffer + IPR_VENDOR_ID_LEN, vpd->vpids.product_id,
  914. IPR_PROD_ID_LEN);
  915. buffer[IPR_VENDOR_ID_LEN + IPR_PROD_ID_LEN] = '\0';
  916. ipr_err("Vendor/Product ID: %s\n", buffer);
  917. memcpy(buffer, vpd->sn, IPR_SERIAL_NUM_LEN);
  918. buffer[IPR_SERIAL_NUM_LEN] = '\0';
  919. ipr_err(" Serial Number: %s\n", buffer);
  920. }
  921. /**
  922. * ipr_log_ext_vpd_compact - Log the passed extended VPD compactly.
  923. * @prefix: string to print at start of printk
  924. * @hostrcb: hostrcb pointer
  925. * @vpd: vendor/product id/sn/wwn struct
  926. *
  927. * Return value:
  928. * none
  929. **/
  930. static void ipr_log_ext_vpd_compact(char *prefix, struct ipr_hostrcb *hostrcb,
  931. struct ipr_ext_vpd *vpd)
  932. {
  933. ipr_log_vpd_compact(prefix, hostrcb, &vpd->vpd);
  934. ipr_hcam_err(hostrcb, "%s WWN: %08X%08X\n", prefix,
  935. be32_to_cpu(vpd->wwid[0]), be32_to_cpu(vpd->wwid[1]));
  936. }
  937. /**
  938. * ipr_log_ext_vpd - Log the passed extended VPD to the error log.
  939. * @vpd: vendor/product id/sn/wwn struct
  940. *
  941. * Return value:
  942. * none
  943. **/
  944. static void ipr_log_ext_vpd(struct ipr_ext_vpd *vpd)
  945. {
  946. ipr_log_vpd(&vpd->vpd);
  947. ipr_err(" WWN: %08X%08X\n", be32_to_cpu(vpd->wwid[0]),
  948. be32_to_cpu(vpd->wwid[1]));
  949. }
  950. /**
  951. * ipr_log_enhanced_cache_error - Log a cache error.
  952. * @ioa_cfg: ioa config struct
  953. * @hostrcb: hostrcb struct
  954. *
  955. * Return value:
  956. * none
  957. **/
  958. static void ipr_log_enhanced_cache_error(struct ipr_ioa_cfg *ioa_cfg,
  959. struct ipr_hostrcb *hostrcb)
  960. {
  961. struct ipr_hostrcb_type_12_error *error =
  962. &hostrcb->hcam.u.error.u.type_12_error;
  963. ipr_err("-----Current Configuration-----\n");
  964. ipr_err("Cache Directory Card Information:\n");
  965. ipr_log_ext_vpd(&error->ioa_vpd);
  966. ipr_err("Adapter Card Information:\n");
  967. ipr_log_ext_vpd(&error->cfc_vpd);
  968. ipr_err("-----Expected Configuration-----\n");
  969. ipr_err("Cache Directory Card Information:\n");
  970. ipr_log_ext_vpd(&error->ioa_last_attached_to_cfc_vpd);
  971. ipr_err("Adapter Card Information:\n");
  972. ipr_log_ext_vpd(&error->cfc_last_attached_to_ioa_vpd);
  973. ipr_err("Additional IOA Data: %08X %08X %08X\n",
  974. be32_to_cpu(error->ioa_data[0]),
  975. be32_to_cpu(error->ioa_data[1]),
  976. be32_to_cpu(error->ioa_data[2]));
  977. }
  978. /**
  979. * ipr_log_cache_error - Log a cache error.
  980. * @ioa_cfg: ioa config struct
  981. * @hostrcb: hostrcb struct
  982. *
  983. * Return value:
  984. * none
  985. **/
  986. static void ipr_log_cache_error(struct ipr_ioa_cfg *ioa_cfg,
  987. struct ipr_hostrcb *hostrcb)
  988. {
  989. struct ipr_hostrcb_type_02_error *error =
  990. &hostrcb->hcam.u.error.u.type_02_error;
  991. ipr_err("-----Current Configuration-----\n");
  992. ipr_err("Cache Directory Card Information:\n");
  993. ipr_log_vpd(&error->ioa_vpd);
  994. ipr_err("Adapter Card Information:\n");
  995. ipr_log_vpd(&error->cfc_vpd);
  996. ipr_err("-----Expected Configuration-----\n");
  997. ipr_err("Cache Directory Card Information:\n");
  998. ipr_log_vpd(&error->ioa_last_attached_to_cfc_vpd);
  999. ipr_err("Adapter Card Information:\n");
  1000. ipr_log_vpd(&error->cfc_last_attached_to_ioa_vpd);
  1001. ipr_err("Additional IOA Data: %08X %08X %08X\n",
  1002. be32_to_cpu(error->ioa_data[0]),
  1003. be32_to_cpu(error->ioa_data[1]),
  1004. be32_to_cpu(error->ioa_data[2]));
  1005. }
  1006. /**
  1007. * ipr_log_enhanced_config_error - Log a configuration error.
  1008. * @ioa_cfg: ioa config struct
  1009. * @hostrcb: hostrcb struct
  1010. *
  1011. * Return value:
  1012. * none
  1013. **/
  1014. static void ipr_log_enhanced_config_error(struct ipr_ioa_cfg *ioa_cfg,
  1015. struct ipr_hostrcb *hostrcb)
  1016. {
  1017. int errors_logged, i;
  1018. struct ipr_hostrcb_device_data_entry_enhanced *dev_entry;
  1019. struct ipr_hostrcb_type_13_error *error;
  1020. error = &hostrcb->hcam.u.error.u.type_13_error;
  1021. errors_logged = be32_to_cpu(error->errors_logged);
  1022. ipr_err("Device Errors Detected/Logged: %d/%d\n",
  1023. be32_to_cpu(error->errors_detected), errors_logged);
  1024. dev_entry = error->dev;
  1025. for (i = 0; i < errors_logged; i++, dev_entry++) {
  1026. ipr_err_separator;
  1027. ipr_phys_res_err(ioa_cfg, dev_entry->dev_res_addr, "Device %d", i + 1);
  1028. ipr_log_ext_vpd(&dev_entry->vpd);
  1029. ipr_err("-----New Device Information-----\n");
  1030. ipr_log_ext_vpd(&dev_entry->new_vpd);
  1031. ipr_err("Cache Directory Card Information:\n");
  1032. ipr_log_ext_vpd(&dev_entry->ioa_last_with_dev_vpd);
  1033. ipr_err("Adapter Card Information:\n");
  1034. ipr_log_ext_vpd(&dev_entry->cfc_last_with_dev_vpd);
  1035. }
  1036. }
  1037. /**
  1038. * ipr_log_config_error - Log a configuration error.
  1039. * @ioa_cfg: ioa config struct
  1040. * @hostrcb: hostrcb struct
  1041. *
  1042. * Return value:
  1043. * none
  1044. **/
  1045. static void ipr_log_config_error(struct ipr_ioa_cfg *ioa_cfg,
  1046. struct ipr_hostrcb *hostrcb)
  1047. {
  1048. int errors_logged, i;
  1049. struct ipr_hostrcb_device_data_entry *dev_entry;
  1050. struct ipr_hostrcb_type_03_error *error;
  1051. error = &hostrcb->hcam.u.error.u.type_03_error;
  1052. errors_logged = be32_to_cpu(error->errors_logged);
  1053. ipr_err("Device Errors Detected/Logged: %d/%d\n",
  1054. be32_to_cpu(error->errors_detected), errors_logged);
  1055. dev_entry = error->dev;
  1056. for (i = 0; i < errors_logged; i++, dev_entry++) {
  1057. ipr_err_separator;
  1058. ipr_phys_res_err(ioa_cfg, dev_entry->dev_res_addr, "Device %d", i + 1);
  1059. ipr_log_vpd(&dev_entry->vpd);
  1060. ipr_err("-----New Device Information-----\n");
  1061. ipr_log_vpd(&dev_entry->new_vpd);
  1062. ipr_err("Cache Directory Card Information:\n");
  1063. ipr_log_vpd(&dev_entry->ioa_last_with_dev_vpd);
  1064. ipr_err("Adapter Card Information:\n");
  1065. ipr_log_vpd(&dev_entry->cfc_last_with_dev_vpd);
  1066. ipr_err("Additional IOA Data: %08X %08X %08X %08X %08X\n",
  1067. be32_to_cpu(dev_entry->ioa_data[0]),
  1068. be32_to_cpu(dev_entry->ioa_data[1]),
  1069. be32_to_cpu(dev_entry->ioa_data[2]),
  1070. be32_to_cpu(dev_entry->ioa_data[3]),
  1071. be32_to_cpu(dev_entry->ioa_data[4]));
  1072. }
  1073. }
  1074. /**
  1075. * ipr_log_enhanced_array_error - Log an array configuration error.
  1076. * @ioa_cfg: ioa config struct
  1077. * @hostrcb: hostrcb struct
  1078. *
  1079. * Return value:
  1080. * none
  1081. **/
  1082. static void ipr_log_enhanced_array_error(struct ipr_ioa_cfg *ioa_cfg,
  1083. struct ipr_hostrcb *hostrcb)
  1084. {
  1085. int i, num_entries;
  1086. struct ipr_hostrcb_type_14_error *error;
  1087. struct ipr_hostrcb_array_data_entry_enhanced *array_entry;
  1088. const u8 zero_sn[IPR_SERIAL_NUM_LEN] = { [0 ... IPR_SERIAL_NUM_LEN-1] = '0' };
  1089. error = &hostrcb->hcam.u.error.u.type_14_error;
  1090. ipr_err_separator;
  1091. ipr_err("RAID %s Array Configuration: %d:%d:%d:%d\n",
  1092. error->protection_level,
  1093. ioa_cfg->host->host_no,
  1094. error->last_func_vset_res_addr.bus,
  1095. error->last_func_vset_res_addr.target,
  1096. error->last_func_vset_res_addr.lun);
  1097. ipr_err_separator;
  1098. array_entry = error->array_member;
  1099. num_entries = min_t(u32, be32_to_cpu(error->num_entries),
  1100. sizeof(error->array_member));
  1101. for (i = 0; i < num_entries; i++, array_entry++) {
  1102. if (!memcmp(array_entry->vpd.vpd.sn, zero_sn, IPR_SERIAL_NUM_LEN))
  1103. continue;
  1104. if (be32_to_cpu(error->exposed_mode_adn) == i)
  1105. ipr_err("Exposed Array Member %d:\n", i);
  1106. else
  1107. ipr_err("Array Member %d:\n", i);
  1108. ipr_log_ext_vpd(&array_entry->vpd);
  1109. ipr_phys_res_err(ioa_cfg, array_entry->dev_res_addr, "Current Location");
  1110. ipr_phys_res_err(ioa_cfg, array_entry->expected_dev_res_addr,
  1111. "Expected Location");
  1112. ipr_err_separator;
  1113. }
  1114. }
  1115. /**
  1116. * ipr_log_array_error - Log an array configuration error.
  1117. * @ioa_cfg: ioa config struct
  1118. * @hostrcb: hostrcb struct
  1119. *
  1120. * Return value:
  1121. * none
  1122. **/
  1123. static void ipr_log_array_error(struct ipr_ioa_cfg *ioa_cfg,
  1124. struct ipr_hostrcb *hostrcb)
  1125. {
  1126. int i;
  1127. struct ipr_hostrcb_type_04_error *error;
  1128. struct ipr_hostrcb_array_data_entry *array_entry;
  1129. const u8 zero_sn[IPR_SERIAL_NUM_LEN] = { [0 ... IPR_SERIAL_NUM_LEN-1] = '0' };
  1130. error = &hostrcb->hcam.u.error.u.type_04_error;
  1131. ipr_err_separator;
  1132. ipr_err("RAID %s Array Configuration: %d:%d:%d:%d\n",
  1133. error->protection_level,
  1134. ioa_cfg->host->host_no,
  1135. error->last_func_vset_res_addr.bus,
  1136. error->last_func_vset_res_addr.target,
  1137. error->last_func_vset_res_addr.lun);
  1138. ipr_err_separator;
  1139. array_entry = error->array_member;
  1140. for (i = 0; i < 18; i++) {
  1141. if (!memcmp(array_entry->vpd.sn, zero_sn, IPR_SERIAL_NUM_LEN))
  1142. continue;
  1143. if (be32_to_cpu(error->exposed_mode_adn) == i)
  1144. ipr_err("Exposed Array Member %d:\n", i);
  1145. else
  1146. ipr_err("Array Member %d:\n", i);
  1147. ipr_log_vpd(&array_entry->vpd);
  1148. ipr_phys_res_err(ioa_cfg, array_entry->dev_res_addr, "Current Location");
  1149. ipr_phys_res_err(ioa_cfg, array_entry->expected_dev_res_addr,
  1150. "Expected Location");
  1151. ipr_err_separator;
  1152. if (i == 9)
  1153. array_entry = error->array_member2;
  1154. else
  1155. array_entry++;
  1156. }
  1157. }
  1158. /**
  1159. * ipr_log_hex_data - Log additional hex IOA error data.
  1160. * @ioa_cfg: ioa config struct
  1161. * @data: IOA error data
  1162. * @len: data length
  1163. *
  1164. * Return value:
  1165. * none
  1166. **/
  1167. static void ipr_log_hex_data(struct ipr_ioa_cfg *ioa_cfg, u32 *data, int len)
  1168. {
  1169. int i;
  1170. if (len == 0)
  1171. return;
  1172. if (ioa_cfg->log_level <= IPR_DEFAULT_LOG_LEVEL)
  1173. len = min_t(int, len, IPR_DEFAULT_MAX_ERROR_DUMP);
  1174. for (i = 0; i < len / 4; i += 4) {
  1175. ipr_err("%08X: %08X %08X %08X %08X\n", i*4,
  1176. be32_to_cpu(data[i]),
  1177. be32_to_cpu(data[i+1]),
  1178. be32_to_cpu(data[i+2]),
  1179. be32_to_cpu(data[i+3]));
  1180. }
  1181. }
  1182. /**
  1183. * ipr_log_enhanced_dual_ioa_error - Log an enhanced dual adapter error.
  1184. * @ioa_cfg: ioa config struct
  1185. * @hostrcb: hostrcb struct
  1186. *
  1187. * Return value:
  1188. * none
  1189. **/
  1190. static void ipr_log_enhanced_dual_ioa_error(struct ipr_ioa_cfg *ioa_cfg,
  1191. struct ipr_hostrcb *hostrcb)
  1192. {
  1193. struct ipr_hostrcb_type_17_error *error;
  1194. error = &hostrcb->hcam.u.error.u.type_17_error;
  1195. error->failure_reason[sizeof(error->failure_reason) - 1] = '\0';
  1196. strstrip(error->failure_reason);
  1197. ipr_hcam_err(hostrcb, "%s [PRC: %08X]\n", error->failure_reason,
  1198. be32_to_cpu(hostrcb->hcam.u.error.prc));
  1199. ipr_log_ext_vpd_compact("Remote IOA", hostrcb, &error->vpd);
  1200. ipr_log_hex_data(ioa_cfg, error->data,
  1201. be32_to_cpu(hostrcb->hcam.length) -
  1202. (offsetof(struct ipr_hostrcb_error, u) +
  1203. offsetof(struct ipr_hostrcb_type_17_error, data)));
  1204. }
  1205. /**
  1206. * ipr_log_dual_ioa_error - Log a dual adapter error.
  1207. * @ioa_cfg: ioa config struct
  1208. * @hostrcb: hostrcb struct
  1209. *
  1210. * Return value:
  1211. * none
  1212. **/
  1213. static void ipr_log_dual_ioa_error(struct ipr_ioa_cfg *ioa_cfg,
  1214. struct ipr_hostrcb *hostrcb)
  1215. {
  1216. struct ipr_hostrcb_type_07_error *error;
  1217. error = &hostrcb->hcam.u.error.u.type_07_error;
  1218. error->failure_reason[sizeof(error->failure_reason) - 1] = '\0';
  1219. strstrip(error->failure_reason);
  1220. ipr_hcam_err(hostrcb, "%s [PRC: %08X]\n", error->failure_reason,
  1221. be32_to_cpu(hostrcb->hcam.u.error.prc));
  1222. ipr_log_vpd_compact("Remote IOA", hostrcb, &error->vpd);
  1223. ipr_log_hex_data(ioa_cfg, error->data,
  1224. be32_to_cpu(hostrcb->hcam.length) -
  1225. (offsetof(struct ipr_hostrcb_error, u) +
  1226. offsetof(struct ipr_hostrcb_type_07_error, data)));
  1227. }
  1228. static const struct {
  1229. u8 active;
  1230. char *desc;
  1231. } path_active_desc[] = {
  1232. { IPR_PATH_NO_INFO, "Path" },
  1233. { IPR_PATH_ACTIVE, "Active path" },
  1234. { IPR_PATH_NOT_ACTIVE, "Inactive path" }
  1235. };
  1236. static const struct {
  1237. u8 state;
  1238. char *desc;
  1239. } path_state_desc[] = {
  1240. { IPR_PATH_STATE_NO_INFO, "has no path state information available" },
  1241. { IPR_PATH_HEALTHY, "is healthy" },
  1242. { IPR_PATH_DEGRADED, "is degraded" },
  1243. { IPR_PATH_FAILED, "is failed" }
  1244. };
  1245. /**
  1246. * ipr_log_fabric_path - Log a fabric path error
  1247. * @hostrcb: hostrcb struct
  1248. * @fabric: fabric descriptor
  1249. *
  1250. * Return value:
  1251. * none
  1252. **/
  1253. static void ipr_log_fabric_path(struct ipr_hostrcb *hostrcb,
  1254. struct ipr_hostrcb_fabric_desc *fabric)
  1255. {
  1256. int i, j;
  1257. u8 path_state = fabric->path_state;
  1258. u8 active = path_state & IPR_PATH_ACTIVE_MASK;
  1259. u8 state = path_state & IPR_PATH_STATE_MASK;
  1260. for (i = 0; i < ARRAY_SIZE(path_active_desc); i++) {
  1261. if (path_active_desc[i].active != active)
  1262. continue;
  1263. for (j = 0; j < ARRAY_SIZE(path_state_desc); j++) {
  1264. if (path_state_desc[j].state != state)
  1265. continue;
  1266. if (fabric->cascaded_expander == 0xff && fabric->phy == 0xff) {
  1267. ipr_hcam_err(hostrcb, "%s %s: IOA Port=%d\n",
  1268. path_active_desc[i].desc, path_state_desc[j].desc,
  1269. fabric->ioa_port);
  1270. } else if (fabric->cascaded_expander == 0xff) {
  1271. ipr_hcam_err(hostrcb, "%s %s: IOA Port=%d, Phy=%d\n",
  1272. path_active_desc[i].desc, path_state_desc[j].desc,
  1273. fabric->ioa_port, fabric->phy);
  1274. } else if (fabric->phy == 0xff) {
  1275. ipr_hcam_err(hostrcb, "%s %s: IOA Port=%d, Cascade=%d\n",
  1276. path_active_desc[i].desc, path_state_desc[j].desc,
  1277. fabric->ioa_port, fabric->cascaded_expander);
  1278. } else {
  1279. ipr_hcam_err(hostrcb, "%s %s: IOA Port=%d, Cascade=%d, Phy=%d\n",
  1280. path_active_desc[i].desc, path_state_desc[j].desc,
  1281. fabric->ioa_port, fabric->cascaded_expander, fabric->phy);
  1282. }
  1283. return;
  1284. }
  1285. }
  1286. ipr_err("Path state=%02X IOA Port=%d Cascade=%d Phy=%d\n", path_state,
  1287. fabric->ioa_port, fabric->cascaded_expander, fabric->phy);
  1288. }
  1289. static const struct {
  1290. u8 type;
  1291. char *desc;
  1292. } path_type_desc[] = {
  1293. { IPR_PATH_CFG_IOA_PORT, "IOA port" },
  1294. { IPR_PATH_CFG_EXP_PORT, "Expander port" },
  1295. { IPR_PATH_CFG_DEVICE_PORT, "Device port" },
  1296. { IPR_PATH_CFG_DEVICE_LUN, "Device LUN" }
  1297. };
  1298. static const struct {
  1299. u8 status;
  1300. char *desc;
  1301. } path_status_desc[] = {
  1302. { IPR_PATH_CFG_NO_PROB, "Functional" },
  1303. { IPR_PATH_CFG_DEGRADED, "Degraded" },
  1304. { IPR_PATH_CFG_FAILED, "Failed" },
  1305. { IPR_PATH_CFG_SUSPECT, "Suspect" },
  1306. { IPR_PATH_NOT_DETECTED, "Missing" },
  1307. { IPR_PATH_INCORRECT_CONN, "Incorrectly connected" }
  1308. };
  1309. static const char *link_rate[] = {
  1310. "unknown",
  1311. "disabled",
  1312. "phy reset problem",
  1313. "spinup hold",
  1314. "port selector",
  1315. "unknown",
  1316. "unknown",
  1317. "unknown",
  1318. "1.5Gbps",
  1319. "3.0Gbps",
  1320. "unknown",
  1321. "unknown",
  1322. "unknown",
  1323. "unknown",
  1324. "unknown",
  1325. "unknown"
  1326. };
  1327. /**
  1328. * ipr_log_path_elem - Log a fabric path element.
  1329. * @hostrcb: hostrcb struct
  1330. * @cfg: fabric path element struct
  1331. *
  1332. * Return value:
  1333. * none
  1334. **/
  1335. static void ipr_log_path_elem(struct ipr_hostrcb *hostrcb,
  1336. struct ipr_hostrcb_config_element *cfg)
  1337. {
  1338. int i, j;
  1339. u8 type = cfg->type_status & IPR_PATH_CFG_TYPE_MASK;
  1340. u8 status = cfg->type_status & IPR_PATH_CFG_STATUS_MASK;
  1341. if (type == IPR_PATH_CFG_NOT_EXIST)
  1342. return;
  1343. for (i = 0; i < ARRAY_SIZE(path_type_desc); i++) {
  1344. if (path_type_desc[i].type != type)
  1345. continue;
  1346. for (j = 0; j < ARRAY_SIZE(path_status_desc); j++) {
  1347. if (path_status_desc[j].status != status)
  1348. continue;
  1349. if (type == IPR_PATH_CFG_IOA_PORT) {
  1350. ipr_hcam_err(hostrcb, "%s %s: Phy=%d, Link rate=%s, WWN=%08X%08X\n",
  1351. path_status_desc[j].desc, path_type_desc[i].desc,
  1352. cfg->phy, link_rate[cfg->link_rate & IPR_PHY_LINK_RATE_MASK],
  1353. be32_to_cpu(cfg->wwid[0]), be32_to_cpu(cfg->wwid[1]));
  1354. } else {
  1355. if (cfg->cascaded_expander == 0xff && cfg->phy == 0xff) {
  1356. ipr_hcam_err(hostrcb, "%s %s: Link rate=%s, WWN=%08X%08X\n",
  1357. path_status_desc[j].desc, path_type_desc[i].desc,
  1358. link_rate[cfg->link_rate & IPR_PHY_LINK_RATE_MASK],
  1359. be32_to_cpu(cfg->wwid[0]), be32_to_cpu(cfg->wwid[1]));
  1360. } else if (cfg->cascaded_expander == 0xff) {
  1361. ipr_hcam_err(hostrcb, "%s %s: Phy=%d, Link rate=%s, "
  1362. "WWN=%08X%08X\n", path_status_desc[j].desc,
  1363. path_type_desc[i].desc, cfg->phy,
  1364. link_rate[cfg->link_rate & IPR_PHY_LINK_RATE_MASK],
  1365. be32_to_cpu(cfg->wwid[0]), be32_to_cpu(cfg->wwid[1]));
  1366. } else if (cfg->phy == 0xff) {
  1367. ipr_hcam_err(hostrcb, "%s %s: Cascade=%d, Link rate=%s, "
  1368. "WWN=%08X%08X\n", path_status_desc[j].desc,
  1369. path_type_desc[i].desc, cfg->cascaded_expander,
  1370. link_rate[cfg->link_rate & IPR_PHY_LINK_RATE_MASK],
  1371. be32_to_cpu(cfg->wwid[0]), be32_to_cpu(cfg->wwid[1]));
  1372. } else {
  1373. ipr_hcam_err(hostrcb, "%s %s: Cascade=%d, Phy=%d, Link rate=%s "
  1374. "WWN=%08X%08X\n", path_status_desc[j].desc,
  1375. path_type_desc[i].desc, cfg->cascaded_expander, cfg->phy,
  1376. link_rate[cfg->link_rate & IPR_PHY_LINK_RATE_MASK],
  1377. be32_to_cpu(cfg->wwid[0]), be32_to_cpu(cfg->wwid[1]));
  1378. }
  1379. }
  1380. return;
  1381. }
  1382. }
  1383. ipr_hcam_err(hostrcb, "Path element=%02X: Cascade=%d Phy=%d Link rate=%s "
  1384. "WWN=%08X%08X\n", cfg->type_status, cfg->cascaded_expander, cfg->phy,
  1385. link_rate[cfg->link_rate & IPR_PHY_LINK_RATE_MASK],
  1386. be32_to_cpu(cfg->wwid[0]), be32_to_cpu(cfg->wwid[1]));
  1387. }
  1388. /**
  1389. * ipr_log_fabric_error - Log a fabric error.
  1390. * @ioa_cfg: ioa config struct
  1391. * @hostrcb: hostrcb struct
  1392. *
  1393. * Return value:
  1394. * none
  1395. **/
  1396. static void ipr_log_fabric_error(struct ipr_ioa_cfg *ioa_cfg,
  1397. struct ipr_hostrcb *hostrcb)
  1398. {
  1399. struct ipr_hostrcb_type_20_error *error;
  1400. struct ipr_hostrcb_fabric_desc *fabric;
  1401. struct ipr_hostrcb_config_element *cfg;
  1402. int i, add_len;
  1403. error = &hostrcb->hcam.u.error.u.type_20_error;
  1404. error->failure_reason[sizeof(error->failure_reason) - 1] = '\0';
  1405. ipr_hcam_err(hostrcb, "%s\n", error->failure_reason);
  1406. add_len = be32_to_cpu(hostrcb->hcam.length) -
  1407. (offsetof(struct ipr_hostrcb_error, u) +
  1408. offsetof(struct ipr_hostrcb_type_20_error, desc));
  1409. for (i = 0, fabric = error->desc; i < error->num_entries; i++) {
  1410. ipr_log_fabric_path(hostrcb, fabric);
  1411. for_each_fabric_cfg(fabric, cfg)
  1412. ipr_log_path_elem(hostrcb, cfg);
  1413. add_len -= be16_to_cpu(fabric->length);
  1414. fabric = (struct ipr_hostrcb_fabric_desc *)
  1415. ((unsigned long)fabric + be16_to_cpu(fabric->length));
  1416. }
  1417. ipr_log_hex_data(ioa_cfg, (u32 *)fabric, add_len);
  1418. }
  1419. /**
  1420. * ipr_log_generic_error - Log an adapter error.
  1421. * @ioa_cfg: ioa config struct
  1422. * @hostrcb: hostrcb struct
  1423. *
  1424. * Return value:
  1425. * none
  1426. **/
  1427. static void ipr_log_generic_error(struct ipr_ioa_cfg *ioa_cfg,
  1428. struct ipr_hostrcb *hostrcb)
  1429. {
  1430. ipr_log_hex_data(ioa_cfg, hostrcb->hcam.u.raw.data,
  1431. be32_to_cpu(hostrcb->hcam.length));
  1432. }
  1433. /**
  1434. * ipr_get_error - Find the specfied IOASC in the ipr_error_table.
  1435. * @ioasc: IOASC
  1436. *
  1437. * This function will return the index of into the ipr_error_table
  1438. * for the specified IOASC. If the IOASC is not in the table,

Large files files are truncated, but you can click here to view the full file