ql4_83xx.c 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594
  1. /*
  2. * QLogic iSCSI HBA Driver
  3. * Copyright (c) 2003-2013 QLogic Corporation
  4. *
  5. * See LICENSE.qla4xxx for copyright and licensing details.
  6. */
  7. #include <linux/ratelimit.h>
  8. #include "ql4_def.h"
  9. #include "ql4_version.h"
  10. #include "ql4_glbl.h"
  11. #include "ql4_dbg.h"
  12. #include "ql4_inline.h"
  13. uint32_t qla4_83xx_rd_reg(struct scsi_qla_host *ha, ulong addr)
  14. {
  15. return readl((void __iomem *)(ha->nx_pcibase + addr));
  16. }
  17. void qla4_83xx_wr_reg(struct scsi_qla_host *ha, ulong addr, uint32_t val)
  18. {
  19. writel(val, (void __iomem *)(ha->nx_pcibase + addr));
  20. }
  21. static int qla4_83xx_set_win_base(struct scsi_qla_host *ha, uint32_t addr)
  22. {
  23. uint32_t val;
  24. int ret_val = QLA_SUCCESS;
  25. qla4_83xx_wr_reg(ha, QLA83XX_CRB_WIN_FUNC(ha->func_num), addr);
  26. val = qla4_83xx_rd_reg(ha, QLA83XX_CRB_WIN_FUNC(ha->func_num));
  27. if (val != addr) {
  28. ql4_printk(KERN_ERR, ha, "%s: Failed to set register window : addr written 0x%x, read 0x%x!\n",
  29. __func__, addr, val);
  30. ret_val = QLA_ERROR;
  31. }
  32. return ret_val;
  33. }
  34. int qla4_83xx_rd_reg_indirect(struct scsi_qla_host *ha, uint32_t addr,
  35. uint32_t *data)
  36. {
  37. int ret_val;
  38. ret_val = qla4_83xx_set_win_base(ha, addr);
  39. if (ret_val == QLA_SUCCESS)
  40. *data = qla4_83xx_rd_reg(ha, QLA83XX_WILDCARD);
  41. else
  42. ql4_printk(KERN_ERR, ha, "%s: failed read of addr 0x%x!\n",
  43. __func__, addr);
  44. return ret_val;
  45. }
  46. int qla4_83xx_wr_reg_indirect(struct scsi_qla_host *ha, uint32_t addr,
  47. uint32_t data)
  48. {
  49. int ret_val;
  50. ret_val = qla4_83xx_set_win_base(ha, addr);
  51. if (ret_val == QLA_SUCCESS)
  52. qla4_83xx_wr_reg(ha, QLA83XX_WILDCARD, data);
  53. else
  54. ql4_printk(KERN_ERR, ha, "%s: failed wrt to addr 0x%x, data 0x%x\n",
  55. __func__, addr, data);
  56. return ret_val;
  57. }
  58. static int qla4_83xx_flash_lock(struct scsi_qla_host *ha)
  59. {
  60. int lock_owner;
  61. int timeout = 0;
  62. uint32_t lock_status = 0;
  63. int ret_val = QLA_SUCCESS;
  64. while (lock_status == 0) {
  65. lock_status = qla4_83xx_rd_reg(ha, QLA83XX_FLASH_LOCK);
  66. if (lock_status)
  67. break;
  68. if (++timeout >= QLA83XX_FLASH_LOCK_TIMEOUT / 20) {
  69. lock_owner = qla4_83xx_rd_reg(ha,
  70. QLA83XX_FLASH_LOCK_ID);
  71. ql4_printk(KERN_ERR, ha, "%s: flash lock by func %d failed, held by func %d\n",
  72. __func__, ha->func_num, lock_owner);
  73. ret_val = QLA_ERROR;
  74. break;
  75. }
  76. msleep(20);
  77. }
  78. qla4_83xx_wr_reg(ha, QLA83XX_FLASH_LOCK_ID, ha->func_num);
  79. return ret_val;
  80. }
  81. static void qla4_83xx_flash_unlock(struct scsi_qla_host *ha)
  82. {
  83. /* Reading FLASH_UNLOCK register unlocks the Flash */
  84. qla4_83xx_wr_reg(ha, QLA83XX_FLASH_LOCK_ID, 0xFF);
  85. qla4_83xx_rd_reg(ha, QLA83XX_FLASH_UNLOCK);
  86. }
  87. int qla4_83xx_flash_read_u32(struct scsi_qla_host *ha, uint32_t flash_addr,
  88. uint8_t *p_data, int u32_word_count)
  89. {
  90. int i;
  91. uint32_t u32_word;
  92. uint32_t addr = flash_addr;
  93. int ret_val = QLA_SUCCESS;
  94. ret_val = qla4_83xx_flash_lock(ha);
  95. if (ret_val == QLA_ERROR)
  96. goto exit_lock_error;
  97. if (addr & 0x03) {
  98. ql4_printk(KERN_ERR, ha, "%s: Illegal addr = 0x%x\n",
  99. __func__, addr);
  100. ret_val = QLA_ERROR;
  101. goto exit_flash_read;
  102. }
  103. for (i = 0; i < u32_word_count; i++) {
  104. ret_val = qla4_83xx_wr_reg_indirect(ha,
  105. QLA83XX_FLASH_DIRECT_WINDOW,
  106. (addr & 0xFFFF0000));
  107. if (ret_val == QLA_ERROR) {
  108. ql4_printk(KERN_ERR, ha, "%s: failed to write addr 0x%x to FLASH_DIRECT_WINDOW\n!",
  109. __func__, addr);
  110. goto exit_flash_read;
  111. }
  112. ret_val = qla4_83xx_rd_reg_indirect(ha,
  113. QLA83XX_FLASH_DIRECT_DATA(addr),
  114. &u32_word);
  115. if (ret_val == QLA_ERROR) {
  116. ql4_printk(KERN_ERR, ha, "%s: failed to read addr 0x%x!\n",
  117. __func__, addr);
  118. goto exit_flash_read;
  119. }
  120. *(__le32 *)p_data = le32_to_cpu(u32_word);
  121. p_data = p_data + 4;
  122. addr = addr + 4;
  123. }
  124. exit_flash_read:
  125. qla4_83xx_flash_unlock(ha);
  126. exit_lock_error:
  127. return ret_val;
  128. }
  129. int qla4_83xx_lockless_flash_read_u32(struct scsi_qla_host *ha,
  130. uint32_t flash_addr, uint8_t *p_data,
  131. int u32_word_count)
  132. {
  133. uint32_t i;
  134. uint32_t u32_word;
  135. uint32_t flash_offset;
  136. uint32_t addr = flash_addr;
  137. int ret_val = QLA_SUCCESS;
  138. flash_offset = addr & (QLA83XX_FLASH_SECTOR_SIZE - 1);
  139. if (addr & 0x3) {
  140. ql4_printk(KERN_ERR, ha, "%s: Illegal addr = 0x%x\n",
  141. __func__, addr);
  142. ret_val = QLA_ERROR;
  143. goto exit_lockless_read;
  144. }
  145. ret_val = qla4_83xx_wr_reg_indirect(ha, QLA83XX_FLASH_DIRECT_WINDOW,
  146. addr);
  147. if (ret_val == QLA_ERROR) {
  148. ql4_printk(KERN_ERR, ha, "%s: failed to write addr 0x%x to FLASH_DIRECT_WINDOW!\n",
  149. __func__, addr);
  150. goto exit_lockless_read;
  151. }
  152. /* Check if data is spread across multiple sectors */
  153. if ((flash_offset + (u32_word_count * sizeof(uint32_t))) >
  154. (QLA83XX_FLASH_SECTOR_SIZE - 1)) {
  155. /* Multi sector read */
  156. for (i = 0; i < u32_word_count; i++) {
  157. ret_val = qla4_83xx_rd_reg_indirect(ha,
  158. QLA83XX_FLASH_DIRECT_DATA(addr),
  159. &u32_word);
  160. if (ret_val == QLA_ERROR) {
  161. ql4_printk(KERN_ERR, ha, "%s: failed to read addr 0x%x!\n",
  162. __func__, addr);
  163. goto exit_lockless_read;
  164. }
  165. *(__le32 *)p_data = le32_to_cpu(u32_word);
  166. p_data = p_data + 4;
  167. addr = addr + 4;
  168. flash_offset = flash_offset + 4;
  169. if (flash_offset > (QLA83XX_FLASH_SECTOR_SIZE - 1)) {
  170. /* This write is needed once for each sector */
  171. ret_val = qla4_83xx_wr_reg_indirect(ha,
  172. QLA83XX_FLASH_DIRECT_WINDOW,
  173. addr);
  174. if (ret_val == QLA_ERROR) {
  175. ql4_printk(KERN_ERR, ha, "%s: failed to write addr 0x%x to FLASH_DIRECT_WINDOW!\n",
  176. __func__, addr);
  177. goto exit_lockless_read;
  178. }
  179. flash_offset = 0;
  180. }
  181. }
  182. } else {
  183. /* Single sector read */
  184. for (i = 0; i < u32_word_count; i++) {
  185. ret_val = qla4_83xx_rd_reg_indirect(ha,
  186. QLA83XX_FLASH_DIRECT_DATA(addr),
  187. &u32_word);
  188. if (ret_val == QLA_ERROR) {
  189. ql4_printk(KERN_ERR, ha, "%s: failed to read addr 0x%x!\n",
  190. __func__, addr);
  191. goto exit_lockless_read;
  192. }
  193. *(__le32 *)p_data = le32_to_cpu(u32_word);
  194. p_data = p_data + 4;
  195. addr = addr + 4;
  196. }
  197. }
  198. exit_lockless_read:
  199. return ret_val;
  200. }
  201. void qla4_83xx_rom_lock_recovery(struct scsi_qla_host *ha)
  202. {
  203. if (qla4_83xx_flash_lock(ha))
  204. ql4_printk(KERN_INFO, ha, "%s: Resetting rom lock\n", __func__);
  205. /*
  206. * We got the lock, or someone else is holding the lock
  207. * since we are restting, forcefully unlock
  208. */
  209. qla4_83xx_flash_unlock(ha);
  210. }
  211. #define INTENT_TO_RECOVER 0x01
  212. #define PROCEED_TO_RECOVER 0x02
  213. static int qla4_83xx_lock_recovery(struct scsi_qla_host *ha)
  214. {
  215. uint32_t lock = 0, lockid;
  216. int ret_val = QLA_ERROR;
  217. lockid = ha->isp_ops->rd_reg_direct(ha, QLA83XX_DRV_LOCKRECOVERY);
  218. /* Check for other Recovery in progress, go wait */
  219. if ((lockid & 0x3) != 0)
  220. goto exit_lock_recovery;
  221. /* Intent to Recover */
  222. ha->isp_ops->wr_reg_direct(ha, QLA83XX_DRV_LOCKRECOVERY,
  223. (ha->func_num << 2) | INTENT_TO_RECOVER);
  224. msleep(200);
  225. /* Check Intent to Recover is advertised */
  226. lockid = ha->isp_ops->rd_reg_direct(ha, QLA83XX_DRV_LOCKRECOVERY);
  227. if ((lockid & 0x3C) != (ha->func_num << 2))
  228. goto exit_lock_recovery;
  229. ql4_printk(KERN_INFO, ha, "%s: IDC Lock recovery initiated for func %d\n",
  230. __func__, ha->func_num);
  231. /* Proceed to Recover */
  232. ha->isp_ops->wr_reg_direct(ha, QLA83XX_DRV_LOCKRECOVERY,
  233. (ha->func_num << 2) | PROCEED_TO_RECOVER);
  234. /* Force Unlock */
  235. ha->isp_ops->wr_reg_direct(ha, QLA83XX_DRV_LOCK_ID, 0xFF);
  236. ha->isp_ops->rd_reg_direct(ha, QLA83XX_DRV_UNLOCK);
  237. /* Clear bits 0-5 in IDC_RECOVERY register*/
  238. ha->isp_ops->wr_reg_direct(ha, QLA83XX_DRV_LOCKRECOVERY, 0);
  239. /* Get lock */
  240. lock = ha->isp_ops->rd_reg_direct(ha, QLA83XX_DRV_LOCK);
  241. if (lock) {
  242. lockid = ha->isp_ops->rd_reg_direct(ha, QLA83XX_DRV_LOCK_ID);
  243. lockid = ((lockid + (1 << 8)) & ~0xFF) | ha->func_num;
  244. ha->isp_ops->wr_reg_direct(ha, QLA83XX_DRV_LOCK_ID, lockid);
  245. ret_val = QLA_SUCCESS;
  246. }
  247. exit_lock_recovery:
  248. return ret_val;
  249. }
  250. #define QLA83XX_DRV_LOCK_MSLEEP 200
  251. int qla4_83xx_drv_lock(struct scsi_qla_host *ha)
  252. {
  253. int timeout = 0;
  254. uint32_t status = 0;
  255. int ret_val = QLA_SUCCESS;
  256. uint32_t first_owner = 0;
  257. uint32_t tmo_owner = 0;
  258. uint32_t lock_id;
  259. uint32_t func_num;
  260. uint32_t lock_cnt;
  261. while (status == 0) {
  262. status = qla4_83xx_rd_reg(ha, QLA83XX_DRV_LOCK);
  263. if (status) {
  264. /* Increment Counter (8-31) and update func_num (0-7) on
  265. * getting a successful lock */
  266. lock_id = qla4_83xx_rd_reg(ha, QLA83XX_DRV_LOCK_ID);
  267. lock_id = ((lock_id + (1 << 8)) & ~0xFF) | ha->func_num;
  268. qla4_83xx_wr_reg(ha, QLA83XX_DRV_LOCK_ID, lock_id);
  269. break;
  270. }
  271. if (timeout == 0)
  272. /* Save counter + ID of function holding the lock for
  273. * first failure */
  274. first_owner = ha->isp_ops->rd_reg_direct(ha,
  275. QLA83XX_DRV_LOCK_ID);
  276. if (++timeout >=
  277. (QLA83XX_DRV_LOCK_TIMEOUT / QLA83XX_DRV_LOCK_MSLEEP)) {
  278. tmo_owner = qla4_83xx_rd_reg(ha, QLA83XX_DRV_LOCK_ID);
  279. func_num = tmo_owner & 0xFF;
  280. lock_cnt = tmo_owner >> 8;
  281. ql4_printk(KERN_INFO, ha, "%s: Lock by func %d failed after 2s, lock held by func %d, lock count %d, first_owner %d\n",
  282. __func__, ha->func_num, func_num, lock_cnt,
  283. (first_owner & 0xFF));
  284. if (first_owner != tmo_owner) {
  285. /* Some other driver got lock, OR same driver
  286. * got lock again (counter value changed), when
  287. * we were waiting for lock.
  288. * Retry for another 2 sec */
  289. ql4_printk(KERN_INFO, ha, "%s: IDC lock failed for func %d\n",
  290. __func__, ha->func_num);
  291. timeout = 0;
  292. } else {
  293. /* Same driver holding lock > 2sec.
  294. * Force Recovery */
  295. ret_val = qla4_83xx_lock_recovery(ha);
  296. if (ret_val == QLA_SUCCESS) {
  297. /* Recovered and got lock */
  298. ql4_printk(KERN_INFO, ha, "%s: IDC lock Recovery by %d successful\n",
  299. __func__, ha->func_num);
  300. break;
  301. }
  302. /* Recovery Failed, some other function
  303. * has the lock, wait for 2secs and retry */
  304. ql4_printk(KERN_INFO, ha, "%s: IDC lock Recovery by %d failed, Retrying timeout\n",
  305. __func__, ha->func_num);
  306. timeout = 0;
  307. }
  308. }
  309. msleep(QLA83XX_DRV_LOCK_MSLEEP);
  310. }
  311. return ret_val;
  312. }
  313. void qla4_83xx_drv_unlock(struct scsi_qla_host *ha)
  314. {
  315. int id;
  316. id = qla4_83xx_rd_reg(ha, QLA83XX_DRV_LOCK_ID);
  317. if ((id & 0xFF) != ha->func_num) {
  318. ql4_printk(KERN_ERR, ha, "%s: IDC Unlock by %d failed, lock owner is %d\n",
  319. __func__, ha->func_num, (id & 0xFF));
  320. return;
  321. }
  322. /* Keep lock counter value, update the ha->func_num to 0xFF */
  323. qla4_83xx_wr_reg(ha, QLA83XX_DRV_LOCK_ID, (id | 0xFF));
  324. qla4_83xx_rd_reg(ha, QLA83XX_DRV_UNLOCK);
  325. }
  326. void qla4_83xx_set_idc_dontreset(struct scsi_qla_host *ha)
  327. {
  328. uint32_t idc_ctrl;
  329. idc_ctrl = qla4_83xx_rd_reg(ha, QLA83XX_IDC_DRV_CTRL);
  330. idc_ctrl |= DONTRESET_BIT0;
  331. qla4_83xx_wr_reg(ha, QLA83XX_IDC_DRV_CTRL, idc_ctrl);
  332. DEBUG2(ql4_printk(KERN_INFO, ha, "%s: idc_ctrl = %d\n", __func__,
  333. idc_ctrl));
  334. }
  335. void qla4_83xx_clear_idc_dontreset(struct scsi_qla_host *ha)
  336. {
  337. uint32_t idc_ctrl;
  338. idc_ctrl = qla4_83xx_rd_reg(ha, QLA83XX_IDC_DRV_CTRL);
  339. idc_ctrl &= ~DONTRESET_BIT0;
  340. qla4_83xx_wr_reg(ha, QLA83XX_IDC_DRV_CTRL, idc_ctrl);
  341. DEBUG2(ql4_printk(KERN_INFO, ha, "%s: idc_ctrl = %d\n", __func__,
  342. idc_ctrl));
  343. }
  344. int qla4_83xx_idc_dontreset(struct scsi_qla_host *ha)
  345. {
  346. uint32_t idc_ctrl;
  347. idc_ctrl = qla4_83xx_rd_reg(ha, QLA83XX_IDC_DRV_CTRL);
  348. return idc_ctrl & DONTRESET_BIT0;
  349. }
  350. /*-------------------------IDC State Machine ---------------------*/
  351. enum {
  352. UNKNOWN_CLASS = 0,
  353. NIC_CLASS,
  354. FCOE_CLASS,
  355. ISCSI_CLASS
  356. };
  357. struct device_info {
  358. int func_num;
  359. int device_type;
  360. int port_num;
  361. };
  362. int qla4_83xx_can_perform_reset(struct scsi_qla_host *ha)
  363. {
  364. uint32_t drv_active;
  365. uint32_t dev_part, dev_part1, dev_part2;
  366. int i;
  367. struct device_info device_map[16];
  368. int func_nibble;
  369. int nibble;
  370. int nic_present = 0;
  371. int iscsi_present = 0;
  372. int iscsi_func_low = 0;
  373. /* Use the dev_partition register to determine the PCI function number
  374. * and then check drv_active register to see which driver is loaded */
  375. dev_part1 = qla4_83xx_rd_reg(ha,
  376. ha->reg_tbl[QLA8XXX_CRB_DEV_PART_INFO]);
  377. dev_part2 = qla4_83xx_rd_reg(ha, QLA83XX_CRB_DEV_PART_INFO2);
  378. drv_active = qla4_83xx_rd_reg(ha, ha->reg_tbl[QLA8XXX_CRB_DRV_ACTIVE]);
  379. /* Each function has 4 bits in dev_partition Info register,
  380. * Lower 2 bits - device type, Upper 2 bits - physical port number */
  381. dev_part = dev_part1;
  382. for (i = nibble = 0; i <= 15; i++, nibble++) {
  383. func_nibble = dev_part & (0xF << (nibble * 4));
  384. func_nibble >>= (nibble * 4);
  385. device_map[i].func_num = i;
  386. device_map[i].device_type = func_nibble & 0x3;
  387. device_map[i].port_num = func_nibble & 0xC;
  388. if (device_map[i].device_type == NIC_CLASS) {
  389. if (drv_active & (1 << device_map[i].func_num)) {
  390. nic_present++;
  391. break;
  392. }
  393. } else if (device_map[i].device_type == ISCSI_CLASS) {
  394. if (drv_active & (1 << device_map[i].func_num)) {
  395. if (!iscsi_present ||
  396. (iscsi_present &&
  397. (iscsi_func_low > device_map[i].func_num)))
  398. iscsi_func_low = device_map[i].func_num;
  399. iscsi_present++;
  400. }
  401. }
  402. /* For function_num[8..15] get info from dev_part2 register */
  403. if (nibble == 7) {
  404. nibble = 0;
  405. dev_part = dev_part2;
  406. }
  407. }
  408. /* NIC, iSCSI and FCOE are the Reset owners based on order, NIC gets
  409. * precedence over iSCSI and FCOE and iSCSI over FCOE, based on drivers
  410. * present. */
  411. if (!nic_present && (ha->func_num == iscsi_func_low)) {
  412. DEBUG2(ql4_printk(KERN_INFO, ha,
  413. "%s: can reset - NIC not present and lower iSCSI function is %d\n",
  414. __func__, ha->func_num));
  415. return 1;
  416. }
  417. return 0;
  418. }
  419. /**
  420. * qla4_83xx_need_reset_handler - Code to start reset sequence
  421. * @ha: pointer to adapter structure
  422. *
  423. * Note: IDC lock must be held upon entry
  424. **/
  425. void qla4_83xx_need_reset_handler(struct scsi_qla_host *ha)
  426. {
  427. uint32_t dev_state, drv_state, drv_active;
  428. unsigned long reset_timeout, dev_init_timeout;
  429. ql4_printk(KERN_INFO, ha, "%s: Performing ISP error recovery\n",
  430. __func__);
  431. if (!test_bit(AF_8XXX_RST_OWNER, &ha->flags)) {
  432. DEBUG2(ql4_printk(KERN_INFO, ha, "%s: reset acknowledged\n",
  433. __func__));
  434. qla4_8xxx_set_rst_ready(ha);
  435. /* Non-reset owners ACK Reset and wait for device INIT state
  436. * as part of Reset Recovery by Reset Owner */
  437. dev_init_timeout = jiffies + (ha->nx_dev_init_timeout * HZ);
  438. do {
  439. if (time_after_eq(jiffies, dev_init_timeout)) {
  440. ql4_printk(KERN_INFO, ha, "%s: Non Reset owner dev init timeout\n",
  441. __func__);
  442. break;
  443. }
  444. ha->isp_ops->idc_unlock(ha);
  445. msleep(1000);
  446. ha->isp_ops->idc_lock(ha);
  447. dev_state = qla4_8xxx_rd_direct(ha,
  448. QLA8XXX_CRB_DEV_STATE);
  449. } while (dev_state == QLA8XXX_DEV_NEED_RESET);
  450. } else {
  451. qla4_8xxx_set_rst_ready(ha);
  452. reset_timeout = jiffies + (ha->nx_reset_timeout * HZ);
  453. drv_state = qla4_8xxx_rd_direct(ha, QLA8XXX_CRB_DRV_STATE);
  454. drv_active = qla4_8xxx_rd_direct(ha, QLA8XXX_CRB_DRV_ACTIVE);
  455. ql4_printk(KERN_INFO, ha, "%s: drv_state = 0x%x, drv_active = 0x%x\n",
  456. __func__, drv_state, drv_active);
  457. while (drv_state != drv_active) {
  458. if (time_after_eq(jiffies, reset_timeout)) {
  459. ql4_printk(KERN_INFO, ha, "%s: %s: RESET TIMEOUT! drv_state: 0x%08x, drv_active: 0x%08x\n",
  460. __func__, DRIVER_NAME, drv_state,
  461. drv_active);
  462. break;
  463. }
  464. ha->isp_ops->idc_unlock(ha);
  465. msleep(1000);
  466. ha->isp_ops->idc_lock(ha);
  467. drv_state = qla4_8xxx_rd_direct(ha,
  468. QLA8XXX_CRB_DRV_STATE);
  469. drv_active = qla4_8xxx_rd_direct(ha,
  470. QLA8XXX_CRB_DRV_ACTIVE);
  471. }
  472. if (drv_state != drv_active) {
  473. ql4_printk(KERN_INFO, ha, "%s: Reset_owner turning off drv_active of non-acking function 0x%x\n",
  474. __func__, (drv_active ^ drv_state));
  475. drv_active = drv_active & drv_state;
  476. qla4_8xxx_wr_direct(ha, QLA8XXX_CRB_DRV_ACTIVE,
  477. drv_active);
  478. }
  479. clear_bit(AF_8XXX_RST_OWNER, &ha->flags);
  480. /* Start Reset Recovery */
  481. qla4_8xxx_device_bootstrap(ha);
  482. }
  483. }
  484. void qla4_83xx_get_idc_param(struct scsi_qla_host *ha)
  485. {
  486. uint32_t idc_params, ret_val;
  487. ret_val = qla4_83xx_flash_read_u32(ha, QLA83XX_IDC_PARAM_ADDR,
  488. (uint8_t *)&idc_params, 1);
  489. if (ret_val == QLA_SUCCESS) {
  490. ha->nx_dev_init_timeout = idc_params & 0xFFFF;
  491. ha->nx_reset_timeout = (idc_params >> 16) & 0xFFFF;
  492. } else {
  493. ha->nx_dev_init_timeout = ROM_DEV_INIT_TIMEOUT;
  494. ha->nx_reset_timeout = ROM_DRV_RESET_ACK_TIMEOUT;
  495. }
  496. DEBUG2(ql4_printk(KERN_DEBUG, ha,
  497. "%s: ha->nx_dev_init_timeout = %d, ha->nx_reset_timeout = %d\n",
  498. __func__, ha->nx_dev_init_timeout,
  499. ha->nx_reset_timeout));
  500. }
  501. /*-------------------------Reset Sequence Functions-----------------------*/
  502. static void qla4_83xx_dump_reset_seq_hdr(struct scsi_qla_host *ha)
  503. {
  504. uint8_t *phdr;
  505. if (!ha->reset_tmplt.buff) {
  506. ql4_printk(KERN_ERR, ha, "%s: Error: Invalid reset_seq_template\n",
  507. __func__);
  508. return;
  509. }
  510. phdr = ha->reset_tmplt.buff;
  511. DEBUG2(ql4_printk(KERN_INFO, ha,
  512. "Reset Template: 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X\n",
  513. *phdr, *(phdr+1), *(phdr+2), *(phdr+3), *(phdr+4),
  514. *(phdr+5), *(phdr+6), *(phdr+7), *(phdr + 8),
  515. *(phdr+9), *(phdr+10), *(phdr+11), *(phdr+12),
  516. *(phdr+13), *(phdr+14), *(phdr+15)));
  517. }
  518. static int qla4_83xx_copy_bootloader(struct scsi_qla_host *ha)
  519. {
  520. uint8_t *p_cache;
  521. uint32_t src, count, size;
  522. uint64_t dest;
  523. int ret_val = QLA_SUCCESS;
  524. src = QLA83XX_BOOTLOADER_FLASH_ADDR;
  525. dest = qla4_83xx_rd_reg(ha, QLA83XX_BOOTLOADER_ADDR);
  526. size = qla4_83xx_rd_reg(ha, QLA83XX_BOOTLOADER_SIZE);
  527. /* 128 bit alignment check */
  528. if (size & 0xF)
  529. size = (size + 16) & ~0xF;
  530. /* 16 byte count */
  531. count = size/16;
  532. p_cache = vmalloc(size);
  533. if (p_cache == NULL) {
  534. ql4_printk(KERN_ERR, ha, "%s: Failed to allocate memory for boot loader cache\n",
  535. __func__);
  536. ret_val = QLA_ERROR;
  537. goto exit_copy_bootloader;
  538. }
  539. ret_val = qla4_83xx_lockless_flash_read_u32(ha, src, p_cache,
  540. size / sizeof(uint32_t));
  541. if (ret_val == QLA_ERROR) {
  542. ql4_printk(KERN_ERR, ha, "%s: Error reading firmware from flash\n",
  543. __func__);
  544. goto exit_copy_error;
  545. }
  546. DEBUG2(ql4_printk(KERN_INFO, ha, "%s: Read firmware from flash\n",
  547. __func__));
  548. /* 128 bit/16 byte write to MS memory */
  549. ret_val = qla4_8xxx_ms_mem_write_128b(ha, dest, (uint32_t *)p_cache,
  550. count);
  551. if (ret_val == QLA_ERROR) {
  552. ql4_printk(KERN_ERR, ha, "%s: Error writing firmware to MS\n",
  553. __func__);
  554. goto exit_copy_error;
  555. }
  556. DEBUG2(ql4_printk(KERN_INFO, ha, "%s: Wrote firmware size %d to MS\n",
  557. __func__, size));
  558. exit_copy_error:
  559. vfree(p_cache);
  560. exit_copy_bootloader:
  561. return ret_val;
  562. }
  563. static int qla4_83xx_check_cmd_peg_status(struct scsi_qla_host *ha)
  564. {
  565. uint32_t val, ret_val = QLA_ERROR;
  566. int retries = CRB_CMDPEG_CHECK_RETRY_COUNT;
  567. do {
  568. val = qla4_83xx_rd_reg(ha, QLA83XX_CMDPEG_STATE);
  569. if (val == PHAN_INITIALIZE_COMPLETE) {
  570. DEBUG2(ql4_printk(KERN_INFO, ha,
  571. "%s: Command Peg initialization complete. State=0x%x\n",
  572. __func__, val));
  573. ret_val = QLA_SUCCESS;
  574. break;
  575. }
  576. msleep(CRB_CMDPEG_CHECK_DELAY);
  577. } while (--retries);
  578. return ret_val;
  579. }
  580. /**
  581. * qla4_83xx_poll_reg - Poll the given CRB addr for duration msecs till
  582. * value read ANDed with test_mask is equal to test_result.
  583. *
  584. * @ha : Pointer to adapter structure
  585. * @addr : CRB register address
  586. * @duration : Poll for total of "duration" msecs
  587. * @test_mask : Mask value read with "test_mask"
  588. * @test_result : Compare (value&test_mask) with test_result.
  589. **/
  590. static int qla4_83xx_poll_reg(struct scsi_qla_host *ha, uint32_t addr,
  591. int duration, uint32_t test_mask,
  592. uint32_t test_result)
  593. {
  594. uint32_t value;
  595. uint8_t retries;
  596. int ret_val = QLA_SUCCESS;
  597. ret_val = qla4_83xx_rd_reg_indirect(ha, addr, &value);
  598. if (ret_val == QLA_ERROR)
  599. goto exit_poll_reg;
  600. retries = duration / 10;
  601. do {
  602. if ((value & test_mask) != test_result) {
  603. msleep(duration / 10);
  604. ret_val = qla4_83xx_rd_reg_indirect(ha, addr, &value);
  605. if (ret_val == QLA_ERROR)
  606. goto exit_poll_reg;
  607. ret_val = QLA_ERROR;
  608. } else {
  609. ret_val = QLA_SUCCESS;
  610. break;
  611. }
  612. } while (retries--);
  613. exit_poll_reg:
  614. if (ret_val == QLA_ERROR) {
  615. ha->reset_tmplt.seq_error++;
  616. ql4_printk(KERN_ERR, ha, "%s: Poll Failed: 0x%08x 0x%08x 0x%08x\n",
  617. __func__, value, test_mask, test_result);
  618. }
  619. return ret_val;
  620. }
  621. static int qla4_83xx_reset_seq_checksum_test(struct scsi_qla_host *ha)
  622. {
  623. uint32_t sum = 0;
  624. uint16_t *buff = (uint16_t *)ha->reset_tmplt.buff;
  625. int u16_count = ha->reset_tmplt.hdr->size / sizeof(uint16_t);
  626. int ret_val;
  627. while (u16_count-- > 0)
  628. sum += *buff++;
  629. while (sum >> 16)
  630. sum = (sum & 0xFFFF) + (sum >> 16);
  631. /* checksum of 0 indicates a valid template */
  632. if (~sum) {
  633. ret_val = QLA_SUCCESS;
  634. } else {
  635. ql4_printk(KERN_ERR, ha, "%s: Reset seq checksum failed\n",
  636. __func__);
  637. ret_val = QLA_ERROR;
  638. }
  639. return ret_val;
  640. }
  641. /**
  642. * qla4_83xx_read_reset_template - Read Reset Template from Flash
  643. * @ha: Pointer to adapter structure
  644. **/
  645. void qla4_83xx_read_reset_template(struct scsi_qla_host *ha)
  646. {
  647. uint8_t *p_buff;
  648. uint32_t addr, tmplt_hdr_def_size, tmplt_hdr_size;
  649. uint32_t ret_val;
  650. ha->reset_tmplt.seq_error = 0;
  651. ha->reset_tmplt.buff = vmalloc(QLA83XX_RESTART_TEMPLATE_SIZE);
  652. if (ha->reset_tmplt.buff == NULL) {
  653. ql4_printk(KERN_ERR, ha, "%s: Failed to allocate reset template resources\n",
  654. __func__);
  655. goto exit_read_reset_template;
  656. }
  657. p_buff = ha->reset_tmplt.buff;
  658. addr = QLA83XX_RESET_TEMPLATE_ADDR;
  659. tmplt_hdr_def_size = sizeof(struct qla4_83xx_reset_template_hdr) /
  660. sizeof(uint32_t);
  661. DEBUG2(ql4_printk(KERN_INFO, ha,
  662. "%s: Read template hdr size %d from Flash\n",
  663. __func__, tmplt_hdr_def_size));
  664. /* Copy template header from flash */
  665. ret_val = qla4_83xx_flash_read_u32(ha, addr, p_buff,
  666. tmplt_hdr_def_size);
  667. if (ret_val != QLA_SUCCESS) {
  668. ql4_printk(KERN_ERR, ha, "%s: Failed to read reset template\n",
  669. __func__);
  670. goto exit_read_template_error;
  671. }
  672. ha->reset_tmplt.hdr =
  673. (struct qla4_83xx_reset_template_hdr *)ha->reset_tmplt.buff;
  674. /* Validate the template header size and signature */
  675. tmplt_hdr_size = ha->reset_tmplt.hdr->hdr_size/sizeof(uint32_t);
  676. if ((tmplt_hdr_size != tmplt_hdr_def_size) ||
  677. (ha->reset_tmplt.hdr->signature != RESET_TMPLT_HDR_SIGNATURE)) {
  678. ql4_printk(KERN_ERR, ha, "%s: Template Header size %d is invalid, tmplt_hdr_def_size %d\n",
  679. __func__, tmplt_hdr_size, tmplt_hdr_def_size);
  680. goto exit_read_template_error;
  681. }
  682. addr = QLA83XX_RESET_TEMPLATE_ADDR + ha->reset_tmplt.hdr->hdr_size;
  683. p_buff = ha->reset_tmplt.buff + ha->reset_tmplt.hdr->hdr_size;
  684. tmplt_hdr_def_size = (ha->reset_tmplt.hdr->size -
  685. ha->reset_tmplt.hdr->hdr_size) / sizeof(uint32_t);
  686. DEBUG2(ql4_printk(KERN_INFO, ha,
  687. "%s: Read rest of the template size %d\n",
  688. __func__, ha->reset_tmplt.hdr->size));
  689. /* Copy rest of the template */
  690. ret_val = qla4_83xx_flash_read_u32(ha, addr, p_buff,
  691. tmplt_hdr_def_size);
  692. if (ret_val != QLA_SUCCESS) {
  693. ql4_printk(KERN_ERR, ha, "%s: Failed to read reset template\n",
  694. __func__);
  695. goto exit_read_template_error;
  696. }
  697. /* Integrity check */
  698. if (qla4_83xx_reset_seq_checksum_test(ha)) {
  699. ql4_printk(KERN_ERR, ha, "%s: Reset Seq checksum failed!\n",
  700. __func__);
  701. goto exit_read_template_error;
  702. }
  703. DEBUG2(ql4_printk(KERN_INFO, ha,
  704. "%s: Reset Seq checksum passed, Get stop, start and init seq offsets\n",
  705. __func__));
  706. /* Get STOP, START, INIT sequence offsets */
  707. ha->reset_tmplt.init_offset = ha->reset_tmplt.buff +
  708. ha->reset_tmplt.hdr->init_seq_offset;
  709. ha->reset_tmplt.start_offset = ha->reset_tmplt.buff +
  710. ha->reset_tmplt.hdr->start_seq_offset;
  711. ha->reset_tmplt.stop_offset = ha->reset_tmplt.buff +
  712. ha->reset_tmplt.hdr->hdr_size;
  713. qla4_83xx_dump_reset_seq_hdr(ha);
  714. goto exit_read_reset_template;
  715. exit_read_template_error:
  716. vfree(ha->reset_tmplt.buff);
  717. exit_read_reset_template:
  718. return;
  719. }
  720. /**
  721. * qla4_83xx_read_write_crb_reg - Read from raddr and write value to waddr.
  722. *
  723. * @ha : Pointer to adapter structure
  724. * @raddr : CRB address to read from
  725. * @waddr : CRB address to write to
  726. **/
  727. static void qla4_83xx_read_write_crb_reg(struct scsi_qla_host *ha,
  728. uint32_t raddr, uint32_t waddr)
  729. {
  730. uint32_t value;
  731. qla4_83xx_rd_reg_indirect(ha, raddr, &value);
  732. qla4_83xx_wr_reg_indirect(ha, waddr, value);
  733. }
  734. /**
  735. * qla4_83xx_rmw_crb_reg - Read Modify Write crb register
  736. *
  737. * This function read value from raddr, AND with test_mask,
  738. * Shift Left,Right/OR/XOR with values RMW header and write value to waddr.
  739. *
  740. * @ha : Pointer to adapter structure
  741. * @raddr : CRB address to read from
  742. * @waddr : CRB address to write to
  743. * @p_rmw_hdr : header with shift/or/xor values.
  744. **/
  745. static void qla4_83xx_rmw_crb_reg(struct scsi_qla_host *ha, uint32_t raddr,
  746. uint32_t waddr,
  747. struct qla4_83xx_rmw *p_rmw_hdr)
  748. {
  749. uint32_t value;
  750. if (p_rmw_hdr->index_a)
  751. value = ha->reset_tmplt.array[p_rmw_hdr->index_a];
  752. else
  753. qla4_83xx_rd_reg_indirect(ha, raddr, &value);
  754. value &= p_rmw_hdr->test_mask;
  755. value <<= p_rmw_hdr->shl;
  756. value >>= p_rmw_hdr->shr;
  757. value |= p_rmw_hdr->or_value;
  758. value ^= p_rmw_hdr->xor_value;
  759. qla4_83xx_wr_reg_indirect(ha, waddr, value);
  760. return;
  761. }
  762. static void qla4_83xx_write_list(struct scsi_qla_host *ha,
  763. struct qla4_83xx_reset_entry_hdr *p_hdr)
  764. {
  765. struct qla4_83xx_entry *p_entry;
  766. uint32_t i;
  767. p_entry = (struct qla4_83xx_entry *)
  768. ((char *)p_hdr + sizeof(struct qla4_83xx_reset_entry_hdr));
  769. for (i = 0; i < p_hdr->count; i++, p_entry++) {
  770. qla4_83xx_wr_reg_indirect(ha, p_entry->arg1, p_entry->arg2);
  771. if (p_hdr->delay)
  772. udelay((uint32_t)(p_hdr->delay));
  773. }
  774. }
  775. static void qla4_83xx_read_write_list(struct scsi_qla_host *ha,
  776. struct qla4_83xx_reset_entry_hdr *p_hdr)
  777. {
  778. struct qla4_83xx_entry *p_entry;
  779. uint32_t i;
  780. p_entry = (struct qla4_83xx_entry *)
  781. ((char *)p_hdr + sizeof(struct qla4_83xx_reset_entry_hdr));
  782. for (i = 0; i < p_hdr->count; i++, p_entry++) {
  783. qla4_83xx_read_write_crb_reg(ha, p_entry->arg1, p_entry->arg2);
  784. if (p_hdr->delay)
  785. udelay((uint32_t)(p_hdr->delay));
  786. }
  787. }
  788. static void qla4_83xx_poll_list(struct scsi_qla_host *ha,
  789. struct qla4_83xx_reset_entry_hdr *p_hdr)
  790. {
  791. long delay;
  792. struct qla4_83xx_entry *p_entry;
  793. struct qla4_83xx_poll *p_poll;
  794. uint32_t i;
  795. uint32_t value;
  796. p_poll = (struct qla4_83xx_poll *)
  797. ((char *)p_hdr + sizeof(struct qla4_83xx_reset_entry_hdr));
  798. /* Entries start after 8 byte qla4_83xx_poll, poll header contains
  799. * the test_mask, test_value. */
  800. p_entry = (struct qla4_83xx_entry *)((char *)p_poll +
  801. sizeof(struct qla4_83xx_poll));
  802. delay = (long)p_hdr->delay;
  803. if (!delay) {
  804. for (i = 0; i < p_hdr->count; i++, p_entry++) {
  805. qla4_83xx_poll_reg(ha, p_entry->arg1, delay,
  806. p_poll->test_mask,
  807. p_poll->test_value);
  808. }
  809. } else {
  810. for (i = 0; i < p_hdr->count; i++, p_entry++) {
  811. if (qla4_83xx_poll_reg(ha, p_entry->arg1, delay,
  812. p_poll->test_mask,
  813. p_poll->test_value)) {
  814. qla4_83xx_rd_reg_indirect(ha, p_entry->arg1,
  815. &value);
  816. qla4_83xx_rd_reg_indirect(ha, p_entry->arg2,
  817. &value);
  818. }
  819. }
  820. }
  821. }
  822. static void qla4_83xx_poll_write_list(struct scsi_qla_host *ha,
  823. struct qla4_83xx_reset_entry_hdr *p_hdr)
  824. {
  825. long delay;
  826. struct qla4_83xx_quad_entry *p_entry;
  827. struct qla4_83xx_poll *p_poll;
  828. uint32_t i;
  829. p_poll = (struct qla4_83xx_poll *)
  830. ((char *)p_hdr + sizeof(struct qla4_83xx_reset_entry_hdr));
  831. p_entry = (struct qla4_83xx_quad_entry *)
  832. ((char *)p_poll + sizeof(struct qla4_83xx_poll));
  833. delay = (long)p_hdr->delay;
  834. for (i = 0; i < p_hdr->count; i++, p_entry++) {
  835. qla4_83xx_wr_reg_indirect(ha, p_entry->dr_addr,
  836. p_entry->dr_value);
  837. qla4_83xx_wr_reg_indirect(ha, p_entry->ar_addr,
  838. p_entry->ar_value);
  839. if (delay) {
  840. if (qla4_83xx_poll_reg(ha, p_entry->ar_addr, delay,
  841. p_poll->test_mask,
  842. p_poll->test_value)) {
  843. DEBUG2(ql4_printk(KERN_INFO, ha,
  844. "%s: Timeout Error: poll list, item_num %d, entry_num %d\n",
  845. __func__, i,
  846. ha->reset_tmplt.seq_index));
  847. }
  848. }
  849. }
  850. }
  851. static void qla4_83xx_read_modify_write(struct scsi_qla_host *ha,
  852. struct qla4_83xx_reset_entry_hdr *p_hdr)
  853. {
  854. struct qla4_83xx_entry *p_entry;
  855. struct qla4_83xx_rmw *p_rmw_hdr;
  856. uint32_t i;
  857. p_rmw_hdr = (struct qla4_83xx_rmw *)
  858. ((char *)p_hdr + sizeof(struct qla4_83xx_reset_entry_hdr));
  859. p_entry = (struct qla4_83xx_entry *)
  860. ((char *)p_rmw_hdr + sizeof(struct qla4_83xx_rmw));
  861. for (i = 0; i < p_hdr->count; i++, p_entry++) {
  862. qla4_83xx_rmw_crb_reg(ha, p_entry->arg1, p_entry->arg2,
  863. p_rmw_hdr);
  864. if (p_hdr->delay)
  865. udelay((uint32_t)(p_hdr->delay));
  866. }
  867. }
  868. static void qla4_83xx_pause(struct scsi_qla_host *ha,
  869. struct qla4_83xx_reset_entry_hdr *p_hdr)
  870. {
  871. if (p_hdr->delay)
  872. mdelay((uint32_t)((long)p_hdr->delay));
  873. }
  874. static void qla4_83xx_poll_read_list(struct scsi_qla_host *ha,
  875. struct qla4_83xx_reset_entry_hdr *p_hdr)
  876. {
  877. long delay;
  878. int index;
  879. struct qla4_83xx_quad_entry *p_entry;
  880. struct qla4_83xx_poll *p_poll;
  881. uint32_t i;
  882. uint32_t value;
  883. p_poll = (struct qla4_83xx_poll *)
  884. ((char *)p_hdr + sizeof(struct qla4_83xx_reset_entry_hdr));
  885. p_entry = (struct qla4_83xx_quad_entry *)
  886. ((char *)p_poll + sizeof(struct qla4_83xx_poll));
  887. delay = (long)p_hdr->delay;
  888. for (i = 0; i < p_hdr->count; i++, p_entry++) {
  889. qla4_83xx_wr_reg_indirect(ha, p_entry->ar_addr,
  890. p_entry->ar_value);
  891. if (delay) {
  892. if (qla4_83xx_poll_reg(ha, p_entry->ar_addr, delay,
  893. p_poll->test_mask,
  894. p_poll->test_value)) {
  895. DEBUG2(ql4_printk(KERN_INFO, ha,
  896. "%s: Timeout Error: poll list, Item_num %d, entry_num %d\n",
  897. __func__, i,
  898. ha->reset_tmplt.seq_index));
  899. } else {
  900. index = ha->reset_tmplt.array_index;
  901. qla4_83xx_rd_reg_indirect(ha, p_entry->dr_addr,
  902. &value);
  903. ha->reset_tmplt.array[index++] = value;
  904. if (index == QLA83XX_MAX_RESET_SEQ_ENTRIES)
  905. ha->reset_tmplt.array_index = 1;
  906. }
  907. }
  908. }
  909. }
  910. static void qla4_83xx_seq_end(struct scsi_qla_host *ha,
  911. struct qla4_83xx_reset_entry_hdr *p_hdr)
  912. {
  913. ha->reset_tmplt.seq_end = 1;
  914. }
  915. static void qla4_83xx_template_end(struct scsi_qla_host *ha,
  916. struct qla4_83xx_reset_entry_hdr *p_hdr)
  917. {
  918. ha->reset_tmplt.template_end = 1;
  919. if (ha->reset_tmplt.seq_error == 0) {
  920. DEBUG2(ql4_printk(KERN_INFO, ha,
  921. "%s: Reset sequence completed SUCCESSFULLY.\n",
  922. __func__));
  923. } else {
  924. ql4_printk(KERN_ERR, ha, "%s: Reset sequence completed with some timeout errors.\n",
  925. __func__);
  926. }
  927. }
  928. /**
  929. * qla4_83xx_process_reset_template - Process reset template.
  930. *
  931. * Process all entries in reset template till entry with SEQ_END opcode,
  932. * which indicates end of the reset template processing. Each entry has a
  933. * Reset Entry header, entry opcode/command, with size of the entry, number
  934. * of entries in sub-sequence and delay in microsecs or timeout in millisecs.
  935. *
  936. * @ha : Pointer to adapter structure
  937. * @p_buff : Common reset entry header.
  938. **/
  939. static void qla4_83xx_process_reset_template(struct scsi_qla_host *ha,
  940. char *p_buff)
  941. {
  942. int index, entries;
  943. struct qla4_83xx_reset_entry_hdr *p_hdr;
  944. char *p_entry = p_buff;
  945. ha->reset_tmplt.seq_end = 0;
  946. ha->reset_tmplt.template_end = 0;
  947. entries = ha->reset_tmplt.hdr->entries;
  948. index = ha->reset_tmplt.seq_index;
  949. for (; (!ha->reset_tmplt.seq_end) && (index < entries); index++) {
  950. p_hdr = (struct qla4_83xx_reset_entry_hdr *)p_entry;
  951. switch (p_hdr->cmd) {
  952. case OPCODE_NOP:
  953. break;
  954. case OPCODE_WRITE_LIST:
  955. qla4_83xx_write_list(ha, p_hdr);
  956. break;
  957. case OPCODE_READ_WRITE_LIST:
  958. qla4_83xx_read_write_list(ha, p_hdr);
  959. break;
  960. case OPCODE_POLL_LIST:
  961. qla4_83xx_poll_list(ha, p_hdr);
  962. break;
  963. case OPCODE_POLL_WRITE_LIST:
  964. qla4_83xx_poll_write_list(ha, p_hdr);
  965. break;
  966. case OPCODE_READ_MODIFY_WRITE:
  967. qla4_83xx_read_modify_write(ha, p_hdr);
  968. break;
  969. case OPCODE_SEQ_PAUSE:
  970. qla4_83xx_pause(ha, p_hdr);
  971. break;
  972. case OPCODE_SEQ_END:
  973. qla4_83xx_seq_end(ha, p_hdr);
  974. break;
  975. case OPCODE_TMPL_END:
  976. qla4_83xx_template_end(ha, p_hdr);
  977. break;
  978. case OPCODE_POLL_READ_LIST:
  979. qla4_83xx_poll_read_list(ha, p_hdr);
  980. break;
  981. default:
  982. ql4_printk(KERN_ERR, ha, "%s: Unknown command ==> 0x%04x on entry = %d\n",
  983. __func__, p_hdr->cmd, index);
  984. break;
  985. }
  986. /* Set pointer to next entry in the sequence. */
  987. p_entry += p_hdr->size;
  988. }
  989. ha->reset_tmplt.seq_index = index;
  990. }
  991. static void qla4_83xx_process_stop_seq(struct scsi_qla_host *ha)
  992. {
  993. ha->reset_tmplt.seq_index = 0;
  994. qla4_83xx_process_reset_template(ha, ha->reset_tmplt.stop_offset);
  995. if (ha->reset_tmplt.seq_end != 1)
  996. ql4_printk(KERN_ERR, ha, "%s: Abrupt STOP Sub-Sequence end.\n",
  997. __func__);
  998. }
  999. static void qla4_83xx_process_start_seq(struct scsi_qla_host *ha)
  1000. {
  1001. qla4_83xx_process_reset_template(ha, ha->reset_tmplt.start_offset);
  1002. if (ha->reset_tmplt.template_end != 1)
  1003. ql4_printk(KERN_ERR, ha, "%s: Abrupt START Sub-Sequence end.\n",
  1004. __func__);
  1005. }
  1006. static void qla4_83xx_process_init_seq(struct scsi_qla_host *ha)
  1007. {
  1008. qla4_83xx_process_reset_template(ha, ha->reset_tmplt.init_offset);
  1009. if (ha->reset_tmplt.seq_end != 1)
  1010. ql4_printk(KERN_ERR, ha, "%s: Abrupt INIT Sub-Sequence end.\n",
  1011. __func__);
  1012. }
  1013. static int qla4_83xx_restart(struct scsi_qla_host *ha)
  1014. {
  1015. int ret_val = QLA_SUCCESS;
  1016. uint32_t idc_ctrl;
  1017. qla4_83xx_process_stop_seq(ha);
  1018. /*
  1019. * Collect minidump.
  1020. * If IDC_CTRL BIT1 is set, clear it on going to INIT state and
  1021. * don't collect minidump
  1022. */
  1023. idc_ctrl = qla4_83xx_rd_reg(ha, QLA83XX_IDC_DRV_CTRL);
  1024. if (idc_ctrl & GRACEFUL_RESET_BIT1) {
  1025. qla4_83xx_wr_reg(ha, QLA83XX_IDC_DRV_CTRL,
  1026. (idc_ctrl & ~GRACEFUL_RESET_BIT1));
  1027. ql4_printk(KERN_INFO, ha, "%s: Graceful RESET: Not collecting minidump\n",
  1028. __func__);
  1029. } else {
  1030. qla4_8xxx_get_minidump(ha);
  1031. }
  1032. qla4_83xx_process_init_seq(ha);
  1033. if (qla4_83xx_copy_bootloader(ha)) {
  1034. ql4_printk(KERN_ERR, ha, "%s: Copy bootloader, firmware restart failed!\n",
  1035. __func__);
  1036. ret_val = QLA_ERROR;
  1037. goto exit_restart;
  1038. }
  1039. qla4_83xx_wr_reg(ha, QLA83XX_FW_IMAGE_VALID, QLA83XX_BOOT_FROM_FLASH);
  1040. qla4_83xx_process_start_seq(ha);
  1041. exit_restart:
  1042. return ret_val;
  1043. }
  1044. int qla4_83xx_start_firmware(struct scsi_qla_host *ha)
  1045. {
  1046. int ret_val = QLA_SUCCESS;
  1047. ret_val = qla4_83xx_restart(ha);
  1048. if (ret_val == QLA_ERROR) {
  1049. ql4_printk(KERN_ERR, ha, "%s: Restart error\n", __func__);
  1050. goto exit_start_fw;
  1051. } else {
  1052. DEBUG2(ql4_printk(KERN_INFO, ha, "%s: Restart done\n",
  1053. __func__));
  1054. }
  1055. ret_val = qla4_83xx_check_cmd_peg_status(ha);
  1056. if (ret_val == QLA_ERROR)
  1057. ql4_printk(KERN_ERR, ha, "%s: Peg not initialized\n",
  1058. __func__);
  1059. exit_start_fw:
  1060. return ret_val;
  1061. }
  1062. /*----------------------Interrupt Related functions ---------------------*/
  1063. static void qla4_83xx_disable_iocb_intrs(struct scsi_qla_host *ha)
  1064. {
  1065. if (test_and_clear_bit(AF_83XX_IOCB_INTR_ON, &ha->flags))
  1066. qla4_8xxx_intr_disable(ha);
  1067. }
  1068. static void qla4_83xx_disable_mbox_intrs(struct scsi_qla_host *ha)
  1069. {
  1070. uint32_t mb_int, ret;
  1071. if (test_and_clear_bit(AF_83XX_MBOX_INTR_ON, &ha->flags)) {
  1072. ret = readl(&ha->qla4_83xx_reg->mbox_int);
  1073. mb_int = ret & ~INT_ENABLE_FW_MB;
  1074. writel(mb_int, &ha->qla4_83xx_reg->mbox_int);
  1075. writel(1, &ha->qla4_83xx_reg->leg_int_mask);
  1076. }
  1077. }
  1078. void qla4_83xx_disable_intrs(struct scsi_qla_host *ha)
  1079. {
  1080. qla4_83xx_disable_mbox_intrs(ha);
  1081. qla4_83xx_disable_iocb_intrs(ha);
  1082. }
  1083. static void qla4_83xx_enable_iocb_intrs(struct scsi_qla_host *ha)
  1084. {
  1085. if (!test_bit(AF_83XX_IOCB_INTR_ON, &ha->flags)) {
  1086. qla4_8xxx_intr_enable(ha);
  1087. set_bit(AF_83XX_IOCB_INTR_ON, &ha->flags);
  1088. }
  1089. }
  1090. void qla4_83xx_enable_mbox_intrs(struct scsi_qla_host *ha)
  1091. {
  1092. uint32_t mb_int;
  1093. if (!test_bit(AF_83XX_MBOX_INTR_ON, &ha->flags)) {
  1094. mb_int = INT_ENABLE_FW_MB;
  1095. writel(mb_int, &ha->qla4_83xx_reg->mbox_int);
  1096. writel(0, &ha->qla4_83xx_reg->leg_int_mask);
  1097. set_bit(AF_83XX_MBOX_INTR_ON, &ha->flags);
  1098. }
  1099. }
  1100. void qla4_83xx_enable_intrs(struct scsi_qla_host *ha)
  1101. {
  1102. qla4_83xx_enable_mbox_intrs(ha);
  1103. qla4_83xx_enable_iocb_intrs(ha);
  1104. }
  1105. void qla4_83xx_queue_mbox_cmd(struct scsi_qla_host *ha, uint32_t *mbx_cmd,
  1106. int incount)
  1107. {
  1108. int i;
  1109. /* Load all mailbox registers, except mailbox 0. */
  1110. for (i = 1; i < incount; i++)
  1111. writel(mbx_cmd[i], &ha->qla4_83xx_reg->mailbox_in[i]);
  1112. writel(mbx_cmd[0], &ha->qla4_83xx_reg->mailbox_in[0]);
  1113. /* Set Host Interrupt register to 1, to tell the firmware that
  1114. * a mailbox command is pending. Firmware after reading the
  1115. * mailbox command, clears the host interrupt register */
  1116. writel(HINT_MBX_INT_PENDING, &ha->qla4_83xx_reg->host_intr);
  1117. }
  1118. void qla4_83xx_process_mbox_intr(struct scsi_qla_host *ha, int outcount)
  1119. {
  1120. int intr_status;
  1121. intr_status = readl(&ha->qla4_83xx_reg->risc_intr);
  1122. if (intr_status) {
  1123. ha->mbox_status_count = outcount;
  1124. ha->isp_ops->interrupt_service_routine(ha, intr_status);
  1125. }
  1126. }
  1127. /**
  1128. * qla4_83xx_isp_reset - Resets ISP and aborts all outstanding commands.
  1129. * @ha: pointer to host adapter structure.
  1130. **/
  1131. int qla4_83xx_isp_reset(struct scsi_qla_host *ha)
  1132. {
  1133. int rval;
  1134. uint32_t dev_state;
  1135. ha->isp_ops->idc_lock(ha);
  1136. dev_state = qla4_8xxx_rd_direct(ha, QLA8XXX_CRB_DEV_STATE);
  1137. if (ql4xdontresethba)
  1138. qla4_83xx_set_idc_dontreset(ha);
  1139. if (dev_state == QLA8XXX_DEV_READY) {
  1140. /* If IDC_CTRL DONTRESETHBA_BIT0 is set dont do reset
  1141. * recovery */
  1142. if (qla4_83xx_idc_dontreset(ha) == DONTRESET_BIT0) {
  1143. ql4_printk(KERN_ERR, ha, "%s: Reset recovery disabled\n",
  1144. __func__);
  1145. rval = QLA_ERROR;
  1146. goto exit_isp_reset;
  1147. }
  1148. DEBUG2(ql4_printk(KERN_INFO, ha, "%s: HW State: NEED RESET\n",
  1149. __func__));
  1150. qla4_8xxx_wr_direct(ha, QLA8XXX_CRB_DEV_STATE,
  1151. QLA8XXX_DEV_NEED_RESET);
  1152. } else {
  1153. /* If device_state is NEED_RESET, go ahead with
  1154. * Reset,irrespective of ql4xdontresethba. This is to allow a
  1155. * non-reset-owner to force a reset. Non-reset-owner sets
  1156. * the IDC_CTRL BIT0 to prevent Reset-owner from doing a Reset
  1157. * and then forces a Reset by setting device_state to
  1158. * NEED_RESET. */
  1159. DEBUG2(ql4_printk(KERN_INFO, ha,
  1160. "%s: HW state already set to NEED_RESET\n",
  1161. __func__));
  1162. }
  1163. /* For ISP8324 and ISP8042, Reset owner is NIC, iSCSI or FCOE based on
  1164. * priority and which drivers are present. Unlike ISP8022, the function
  1165. * setting NEED_RESET, may not be the Reset owner. */
  1166. if (qla4_83xx_can_perform_reset(ha))
  1167. set_bit(AF_8XXX_RST_OWNER, &ha->flags);
  1168. ha->isp_ops->idc_unlock(ha);
  1169. rval = qla4_8xxx_device_state_handler(ha);
  1170. ha->isp_ops->idc_lock(ha);
  1171. qla4_8xxx_clear_rst_ready(ha);
  1172. exit_isp_reset:
  1173. ha->isp_ops->idc_unlock(ha);
  1174. if (rval == QLA_SUCCESS)
  1175. clear_bit(AF_FW_RECOVERY, &ha->flags);
  1176. return rval;
  1177. }
  1178. static void qla4_83xx_dump_pause_control_regs(struct scsi_qla_host *ha)
  1179. {
  1180. u32 val = 0, val1 = 0;
  1181. int i, status = QLA_SUCCESS;
  1182. status = qla4_83xx_rd_reg_indirect(ha, QLA83XX_SRE_SHIM_CONTROL, &val);
  1183. DEBUG2(ql4_printk(KERN_INFO, ha, "SRE-Shim Ctrl:0x%x\n", val));
  1184. /* Port 0 Rx Buffer Pause Threshold Registers. */
  1185. DEBUG2(ql4_printk(KERN_INFO, ha,
  1186. "Port 0 Rx Buffer Pause Threshold Registers[TC7..TC0]:"));
  1187. for (i = 0; i < 8; i++) {
  1188. status = qla4_83xx_rd_reg_indirect(ha,
  1189. QLA83XX_PORT0_RXB_PAUSE_THRS + (i * 0x4), &val);
  1190. DEBUG2(pr_info("0x%x ", val));
  1191. }
  1192. DEBUG2(pr_info("\n"));
  1193. /* Port 1 Rx Buffer Pause Threshold Registers. */
  1194. DEBUG2(ql4_printk(KERN_INFO, ha,
  1195. "Port 1 Rx Buffer Pause Threshold Registers[TC7..TC0]:"));
  1196. for (i = 0; i < 8; i++) {
  1197. status = qla4_83xx_rd_reg_indirect(ha,
  1198. QLA83XX_PORT1_RXB_PAUSE_THRS + (i * 0x4), &val);
  1199. DEBUG2(pr_info("0x%x ", val));
  1200. }
  1201. DEBUG2(pr_info("\n"));
  1202. /* Port 0 RxB Traffic Class Max Cell Registers. */
  1203. DEBUG2(ql4_printk(KERN_INFO, ha,
  1204. "Port 0 RxB Traffic Class Max Cell Registers[3..0]:"));
  1205. for (i = 0; i < 4; i++) {
  1206. status = qla4_83xx_rd_reg_indirect(ha,
  1207. QLA83XX_PORT0_RXB_TC_MAX_CELL + (i * 0x4), &val);
  1208. DEBUG2(pr_info("0x%x ", val));
  1209. }
  1210. DEBUG2(pr_info("\n"));
  1211. /* Port 1 RxB Traffic Class Max Cell Registers. */
  1212. DEBUG2(ql4_printk(KERN_INFO, ha,
  1213. "Port 1 RxB Traffic Class Max Cell Registers[3..0]:"));
  1214. for (i = 0; i < 4; i++) {
  1215. status = qla4_83xx_rd_reg_indirect(ha,
  1216. QLA83XX_PORT1_RXB_TC_MAX_CELL + (i * 0x4), &val);
  1217. DEBUG2(pr_info("0x%x ", val));
  1218. }
  1219. DEBUG2(pr_info("\n"));
  1220. /* Port 0 RxB Rx Traffic Class Stats. */
  1221. DEBUG2(ql4_printk(KERN_INFO, ha,
  1222. "Port 0 RxB Rx Traffic Class Stats [TC7..TC0]"));
  1223. for (i = 7; i >= 0; i--) {
  1224. status = qla4_83xx_rd_reg_indirect(ha,
  1225. QLA83XX_PORT0_RXB_TC_STATS,
  1226. &val);
  1227. val &= ~(0x7 << 29); /* Reset bits 29 to 31 */
  1228. qla4_83xx_wr_reg_indirect(ha, QLA83XX_PORT0_RXB_TC_STATS,
  1229. (val | (i << 29)));
  1230. status = qla4_83xx_rd_reg_indirect(ha,
  1231. QLA83XX_PORT0_RXB_TC_STATS,
  1232. &val);
  1233. DEBUG2(pr_info("0x%x ", val));
  1234. }
  1235. DEBUG2(pr_info("\n"));
  1236. /* Port 1 RxB Rx Traffic Class Stats. */
  1237. DEBUG2(ql4_printk(KERN_INFO, ha,
  1238. "Port 1 RxB Rx Traffic Class Stats [TC7..TC0]"));
  1239. for (i = 7; i >= 0; i--) {
  1240. status = qla4_83xx_rd_reg_indirect(ha,
  1241. QLA83XX_PORT1_RXB_TC_STATS,
  1242. &val);
  1243. val &= ~(0x7 << 29); /* Reset bits 29 to 31 */
  1244. qla4_83xx_wr_reg_indirect(ha, QLA83XX_PORT1_RXB_TC_STATS,
  1245. (val | (i << 29)));
  1246. status = qla4_83xx_rd_reg_indirect(ha,
  1247. QLA83XX_PORT1_RXB_TC_STATS,
  1248. &val);
  1249. DEBUG2(pr_info("0x%x ", val));
  1250. }
  1251. DEBUG2(pr_info("\n"));
  1252. status = qla4_83xx_rd_reg_indirect(ha, QLA83XX_PORT2_IFB_PAUSE_THRS,
  1253. &val);
  1254. status = qla4_83xx_rd_reg_indirect(ha, QLA83XX_PORT3_IFB_PAUSE_THRS,
  1255. &val1);
  1256. DEBUG2(ql4_printk(KERN_INFO, ha,
  1257. "IFB-Pause Thresholds: Port 2:0x%x, Port 3:0x%x\n",
  1258. val, val1));
  1259. }
  1260. static void __qla4_83xx_disable_pause(struct scsi_qla_host *ha)
  1261. {
  1262. int i;
  1263. /* set SRE-Shim Control Register */
  1264. qla4_83xx_wr_reg_indirect(ha, QLA83XX_SRE_SHIM_CONTROL,
  1265. QLA83XX_SET_PAUSE_VAL);
  1266. for (i = 0; i < 8; i++) {
  1267. /* Port 0 Rx Buffer Pause Threshold Registers. */
  1268. qla4_83xx_wr_reg_indirect(ha,
  1269. QLA83XX_PORT0_RXB_PAUSE_THRS + (i * 0x4),
  1270. QLA83XX_SET_PAUSE_VAL);
  1271. /* Port 1 Rx Buffer Pause Threshold Registers. */
  1272. qla4_83xx_wr_reg_indirect(ha,
  1273. QLA83XX_PORT1_RXB_PAUSE_THRS + (i * 0x4),
  1274. QLA83XX_SET_PAUSE_VAL);
  1275. }
  1276. for (i = 0; i < 4; i++) {
  1277. /* Port 0 RxB Traffic Class Max Cell Registers. */
  1278. qla4_83xx_wr_reg_indirect(ha,
  1279. QLA83XX_PORT0_RXB_TC_MAX_CELL + (i * 0x4),
  1280. QLA83XX_SET_TC_MAX_CELL_VAL);
  1281. /* Port 1 RxB Traffic Class Max Cell Registers. */
  1282. qla4_83xx_wr_reg_indirect(ha,
  1283. QLA83XX_PORT1_RXB_TC_MAX_CELL + (i * 0x4),
  1284. QLA83XX_SET_TC_MAX_CELL_VAL);
  1285. }
  1286. qla4_83xx_wr_reg_indirect(ha, QLA83XX_PORT2_IFB_PAUSE_THRS,
  1287. QLA83XX_SET_PAUSE_VAL);
  1288. qla4_83xx_wr_reg_indirect(ha, QLA83XX_PORT3_IFB_PAUSE_THRS,
  1289. QLA83XX_SET_PAUSE_VAL);
  1290. ql4_printk(KERN_INFO, ha, "Disabled pause frames successfully.\n");
  1291. }
  1292. /**
  1293. * qla4_83xx_eport_init - Initialize EPort.
  1294. * @ha: Pointer to host adapter structure.
  1295. *
  1296. * If EPort hardware is in reset state before disabling pause, there would be
  1297. * serious hardware wedging issues. To prevent this perform eport init everytime
  1298. * before disabling pause frames.
  1299. **/
  1300. static void qla4_83xx_eport_init(struct scsi_qla_host *ha)
  1301. {
  1302. /* Clear the 8 registers */
  1303. qla4_83xx_wr_reg_indirect(ha, QLA83XX_RESET_REG, 0x0);
  1304. qla4_83xx_wr_reg_indirect(ha, QLA83XX_RESET_PORT0, 0x0);
  1305. qla4_83xx_wr_reg_indirect(ha, QLA83XX_RESET_PORT1, 0x0);
  1306. qla4_83xx_wr_reg_indirect(ha, QLA83XX_RESET_PORT2, 0x0);
  1307. qla4_83xx_wr_reg_indirect(ha, QLA83XX_RESET_PORT3, 0x0);
  1308. qla4_83xx_wr_reg_indirect(ha, QLA83XX_RESET_SRE_SHIM, 0x0);
  1309. qla4_83xx_wr_reg_indirect(ha, QLA83XX_RESET_EPG_SHIM, 0x0);
  1310. qla4_83xx_wr_reg_indirect(ha, QLA83XX_RESET_ETHER_PCS, 0x0);
  1311. /* Write any value to Reset Control register */
  1312. qla4_83xx_wr_reg_indirect(ha, QLA83XX_RESET_CONTROL, 0xFF);
  1313. ql4_printk(KERN_INFO, ha, "EPORT is out of reset.\n");
  1314. }
  1315. void qla4_83xx_disable_pause(struct scsi_qla_host *ha)
  1316. {
  1317. ha->isp_ops->idc_lock(ha);
  1318. /* Before disabling pause frames, ensure that eport is not in reset */
  1319. qla4_83xx_eport_init(ha);
  1320. qla4_83xx_dump_pause_control_regs(ha);
  1321. __qla4_83xx_disable_pause(ha);
  1322. ha->isp_ops->idc_unlock(ha);
  1323. }
  1324. /**
  1325. * qla4_83xx_is_detached - Check if we are marked invisible.
  1326. * @ha: Pointer to host adapter structure.
  1327. **/
  1328. int qla4_83xx_is_detached(struct scsi_qla_host *ha)
  1329. {
  1330. uint32_t drv_active;
  1331. drv_active = qla4_8xxx_rd_direct(ha, QLA8XXX_CRB_DRV_ACTIVE);
  1332. if (test_bit(AF_INIT_DONE, &ha->flags) &&
  1333. !(drv_active & (1 << ha->func_num))) {
  1334. DEBUG2(ql4_printk(KERN_INFO, ha, "%s: drv_active = 0x%X\n",
  1335. __func__, drv_active));
  1336. return QLA_SUCCESS;
  1337. }
  1338. return QLA_ERROR;
  1339. }