ql4_isr.c 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627
  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 "ql4_def.h"
  8. #include "ql4_glbl.h"
  9. #include "ql4_dbg.h"
  10. #include "ql4_inline.h"
  11. /**
  12. * qla4xxx_copy_sense - copy sense data into cmd sense buffer
  13. * @ha: Pointer to host adapter structure.
  14. * @sts_entry: Pointer to status entry structure.
  15. * @srb: Pointer to srb structure.
  16. **/
  17. static void qla4xxx_copy_sense(struct scsi_qla_host *ha,
  18. struct status_entry *sts_entry,
  19. struct srb *srb)
  20. {
  21. struct scsi_cmnd *cmd = srb->cmd;
  22. uint16_t sense_len;
  23. memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
  24. sense_len = le16_to_cpu(sts_entry->senseDataByteCnt);
  25. if (sense_len == 0) {
  26. DEBUG2(ql4_printk(KERN_INFO, ha, "scsi%ld:%d:%d:%llu: %s:"
  27. " sense len 0\n", ha->host_no,
  28. cmd->device->channel, cmd->device->id,
  29. cmd->device->lun, __func__));
  30. ha->status_srb = NULL;
  31. return;
  32. }
  33. /* Save total available sense length,
  34. * not to exceed cmd's sense buffer size */
  35. sense_len = min_t(uint16_t, sense_len, SCSI_SENSE_BUFFERSIZE);
  36. srb->req_sense_ptr = cmd->sense_buffer;
  37. srb->req_sense_len = sense_len;
  38. /* Copy sense from sts_entry pkt */
  39. sense_len = min_t(uint16_t, sense_len, IOCB_MAX_SENSEDATA_LEN);
  40. memcpy(cmd->sense_buffer, sts_entry->senseData, sense_len);
  41. DEBUG2(printk(KERN_INFO "scsi%ld:%d:%d:%llu: %s: sense key = %x, "
  42. "ASL= %02x, ASC/ASCQ = %02x/%02x\n", ha->host_no,
  43. cmd->device->channel, cmd->device->id,
  44. cmd->device->lun, __func__,
  45. sts_entry->senseData[2] & 0x0f,
  46. sts_entry->senseData[7],
  47. sts_entry->senseData[12],
  48. sts_entry->senseData[13]));
  49. DEBUG5(qla4xxx_dump_buffer(cmd->sense_buffer, sense_len));
  50. srb->flags |= SRB_GOT_SENSE;
  51. /* Update srb, in case a sts_cont pkt follows */
  52. srb->req_sense_ptr += sense_len;
  53. srb->req_sense_len -= sense_len;
  54. if (srb->req_sense_len != 0)
  55. ha->status_srb = srb;
  56. else
  57. ha->status_srb = NULL;
  58. }
  59. /**
  60. * qla4xxx_status_cont_entry - Process a Status Continuations entry.
  61. * @ha: SCSI driver HA context
  62. * @sts_cont: Entry pointer
  63. *
  64. * Extended sense data.
  65. */
  66. static void
  67. qla4xxx_status_cont_entry(struct scsi_qla_host *ha,
  68. struct status_cont_entry *sts_cont)
  69. {
  70. struct srb *srb = ha->status_srb;
  71. struct scsi_cmnd *cmd;
  72. uint16_t sense_len;
  73. if (srb == NULL)
  74. return;
  75. cmd = srb->cmd;
  76. if (cmd == NULL) {
  77. DEBUG2(printk(KERN_INFO "scsi%ld: %s: Cmd already returned "
  78. "back to OS srb=%p srb->state:%d\n", ha->host_no,
  79. __func__, srb, srb->state));
  80. ha->status_srb = NULL;
  81. return;
  82. }
  83. /* Copy sense data. */
  84. sense_len = min_t(uint16_t, srb->req_sense_len,
  85. IOCB_MAX_EXT_SENSEDATA_LEN);
  86. memcpy(srb->req_sense_ptr, sts_cont->ext_sense_data, sense_len);
  87. DEBUG5(qla4xxx_dump_buffer(srb->req_sense_ptr, sense_len));
  88. srb->req_sense_ptr += sense_len;
  89. srb->req_sense_len -= sense_len;
  90. /* Place command on done queue. */
  91. if (srb->req_sense_len == 0) {
  92. kref_put(&srb->srb_ref, qla4xxx_srb_compl);
  93. ha->status_srb = NULL;
  94. }
  95. }
  96. /**
  97. * qla4xxx_status_entry - processes status IOCBs
  98. * @ha: Pointer to host adapter structure.
  99. * @sts_entry: Pointer to status entry structure.
  100. **/
  101. static void qla4xxx_status_entry(struct scsi_qla_host *ha,
  102. struct status_entry *sts_entry)
  103. {
  104. uint8_t scsi_status;
  105. struct scsi_cmnd *cmd;
  106. struct srb *srb;
  107. struct ddb_entry *ddb_entry;
  108. uint32_t residual;
  109. srb = qla4xxx_del_from_active_array(ha, le32_to_cpu(sts_entry->handle));
  110. if (!srb) {
  111. ql4_printk(KERN_WARNING, ha, "%s invalid status entry: "
  112. "handle=0x%0x, srb=%p\n", __func__,
  113. sts_entry->handle, srb);
  114. if (is_qla80XX(ha))
  115. set_bit(DPC_RESET_HA_FW_CONTEXT, &ha->dpc_flags);
  116. else
  117. set_bit(DPC_RESET_HA, &ha->dpc_flags);
  118. return;
  119. }
  120. cmd = srb->cmd;
  121. if (cmd == NULL) {
  122. DEBUG2(printk("scsi%ld: %s: Command already returned back to "
  123. "OS pkt->handle=%d srb=%p srb->state:%d\n",
  124. ha->host_no, __func__, sts_entry->handle,
  125. srb, srb->state));
  126. ql4_printk(KERN_WARNING, ha, "Command is NULL:"
  127. " already returned to OS (srb=%p)\n", srb);
  128. return;
  129. }
  130. ddb_entry = srb->ddb;
  131. if (ddb_entry == NULL) {
  132. cmd->result = DID_NO_CONNECT << 16;
  133. goto status_entry_exit;
  134. }
  135. residual = le32_to_cpu(sts_entry->residualByteCnt);
  136. /* Translate ISP error to a Linux SCSI error. */
  137. scsi_status = sts_entry->scsiStatus;
  138. switch (sts_entry->completionStatus) {
  139. case SCS_COMPLETE:
  140. if (sts_entry->iscsiFlags & ISCSI_FLAG_RESIDUAL_OVER) {
  141. cmd->result = DID_ERROR << 16;
  142. break;
  143. }
  144. if (sts_entry->iscsiFlags &ISCSI_FLAG_RESIDUAL_UNDER) {
  145. scsi_set_resid(cmd, residual);
  146. if (!scsi_status && ((scsi_bufflen(cmd) - residual) <
  147. cmd->underflow)) {
  148. cmd->result = DID_ERROR << 16;
  149. DEBUG2(printk("scsi%ld:%d:%d:%llu: %s: "
  150. "Mid-layer Data underrun0, "
  151. "xferlen = 0x%x, "
  152. "residual = 0x%x\n", ha->host_no,
  153. cmd->device->channel,
  154. cmd->device->id,
  155. cmd->device->lun, __func__,
  156. scsi_bufflen(cmd), residual));
  157. break;
  158. }
  159. }
  160. cmd->result = DID_OK << 16 | scsi_status;
  161. if (scsi_status != SCSI_CHECK_CONDITION)
  162. break;
  163. /* Copy Sense Data into sense buffer. */
  164. qla4xxx_copy_sense(ha, sts_entry, srb);
  165. break;
  166. case SCS_INCOMPLETE:
  167. /* Always set the status to DID_ERROR, since
  168. * all conditions result in that status anyway */
  169. cmd->result = DID_ERROR << 16;
  170. break;
  171. case SCS_RESET_OCCURRED:
  172. DEBUG2(printk("scsi%ld:%d:%d:%llu: %s: Device RESET occurred\n",
  173. ha->host_no, cmd->device->channel,
  174. cmd->device->id, cmd->device->lun, __func__));
  175. cmd->result = DID_RESET << 16;
  176. break;
  177. case SCS_ABORTED:
  178. DEBUG2(printk("scsi%ld:%d:%d:%llu: %s: Abort occurred\n",
  179. ha->host_no, cmd->device->channel,
  180. cmd->device->id, cmd->device->lun, __func__));
  181. cmd->result = DID_RESET << 16;
  182. break;
  183. case SCS_TIMEOUT:
  184. DEBUG2(printk(KERN_INFO "scsi%ld:%d:%d:%llu: Timeout\n",
  185. ha->host_no, cmd->device->channel,
  186. cmd->device->id, cmd->device->lun));
  187. cmd->result = DID_TRANSPORT_DISRUPTED << 16;
  188. /*
  189. * Mark device missing so that we won't continue to send
  190. * I/O to this device. We should get a ddb state change
  191. * AEN soon.
  192. */
  193. if (iscsi_is_session_online(ddb_entry->sess))
  194. qla4xxx_mark_device_missing(ddb_entry->sess);
  195. break;
  196. case SCS_DATA_UNDERRUN:
  197. case SCS_DATA_OVERRUN:
  198. if ((sts_entry->iscsiFlags & ISCSI_FLAG_RESIDUAL_OVER) ||
  199. (sts_entry->completionStatus == SCS_DATA_OVERRUN)) {
  200. DEBUG2(printk("scsi%ld:%d:%d:%llu: %s: " "Data overrun\n",
  201. ha->host_no,
  202. cmd->device->channel, cmd->device->id,
  203. cmd->device->lun, __func__));
  204. cmd->result = DID_ERROR << 16;
  205. break;
  206. }
  207. scsi_set_resid(cmd, residual);
  208. if (sts_entry->iscsiFlags & ISCSI_FLAG_RESIDUAL_UNDER) {
  209. /* Both the firmware and target reported UNDERRUN:
  210. *
  211. * MID-LAYER UNDERFLOW case:
  212. * Some kernels do not properly detect midlayer
  213. * underflow, so we manually check it and return
  214. * ERROR if the minimum required data was not
  215. * received.
  216. *
  217. * ALL OTHER cases:
  218. * Fall thru to check scsi_status
  219. */
  220. if (!scsi_status && (scsi_bufflen(cmd) - residual) <
  221. cmd->underflow) {
  222. DEBUG2(ql4_printk(KERN_INFO, ha,
  223. "scsi%ld:%d:%d:%llu: %s: Mid-layer Data underrun, xferlen = 0x%x,residual = 0x%x\n",
  224. ha->host_no,
  225. cmd->device->channel,
  226. cmd->device->id,
  227. cmd->device->lun, __func__,
  228. scsi_bufflen(cmd),
  229. residual));
  230. cmd->result = DID_ERROR << 16;
  231. break;
  232. }
  233. } else if (scsi_status != SAM_STAT_TASK_SET_FULL &&
  234. scsi_status != SAM_STAT_BUSY) {
  235. /*
  236. * The firmware reports UNDERRUN, but the target does
  237. * not report it:
  238. *
  239. * scsi_status | host_byte device_byte
  240. * | (19:16) (7:0)
  241. * ============= | ========= ===========
  242. * TASK_SET_FULL | DID_OK scsi_status
  243. * BUSY | DID_OK scsi_status
  244. * ALL OTHERS | DID_ERROR scsi_status
  245. *
  246. * Note: If scsi_status is task set full or busy,
  247. * then this else if would fall thru to check the
  248. * scsi_status and return DID_OK.
  249. */
  250. DEBUG2(ql4_printk(KERN_INFO, ha,
  251. "scsi%ld:%d:%d:%llu: %s: Dropped frame(s) detected (0x%x of 0x%x bytes).\n",
  252. ha->host_no,
  253. cmd->device->channel,
  254. cmd->device->id,
  255. cmd->device->lun, __func__,
  256. residual,
  257. scsi_bufflen(cmd)));
  258. cmd->result = DID_ERROR << 16 | scsi_status;
  259. goto check_scsi_status;
  260. }
  261. cmd->result = DID_OK << 16 | scsi_status;
  262. check_scsi_status:
  263. if (scsi_status == SAM_STAT_CHECK_CONDITION)
  264. qla4xxx_copy_sense(ha, sts_entry, srb);
  265. break;
  266. case SCS_DEVICE_LOGGED_OUT:
  267. case SCS_DEVICE_UNAVAILABLE:
  268. DEBUG2(printk(KERN_INFO "scsi%ld:%d:%d:%llu: SCS_DEVICE "
  269. "state: 0x%x\n", ha->host_no,
  270. cmd->device->channel, cmd->device->id,
  271. cmd->device->lun, sts_entry->completionStatus));
  272. /*
  273. * Mark device missing so that we won't continue to
  274. * send I/O to this device. We should get a ddb
  275. * state change AEN soon.
  276. */
  277. if (iscsi_is_session_online(ddb_entry->sess))
  278. qla4xxx_mark_device_missing(ddb_entry->sess);
  279. cmd->result = DID_TRANSPORT_DISRUPTED << 16;
  280. break;
  281. case SCS_QUEUE_FULL:
  282. /*
  283. * SCSI Mid-Layer handles device queue full
  284. */
  285. cmd->result = DID_OK << 16 | sts_entry->scsiStatus;
  286. DEBUG2(printk("scsi%ld:%d:%llu: %s: QUEUE FULL detected "
  287. "compl=%02x, scsi=%02x, state=%02x, iFlags=%02x,"
  288. " iResp=%02x\n", ha->host_no, cmd->device->id,
  289. cmd->device->lun, __func__,
  290. sts_entry->completionStatus,
  291. sts_entry->scsiStatus, sts_entry->state_flags,
  292. sts_entry->iscsiFlags,
  293. sts_entry->iscsiResponse));
  294. break;
  295. default:
  296. cmd->result = DID_ERROR << 16;
  297. break;
  298. }
  299. status_entry_exit:
  300. /* complete the request, if not waiting for status_continuation pkt */
  301. srb->cc_stat = sts_entry->completionStatus;
  302. if (ha->status_srb == NULL)
  303. kref_put(&srb->srb_ref, qla4xxx_srb_compl);
  304. }
  305. /**
  306. * qla4xxx_passthru_status_entry - processes passthru status IOCBs (0x3C)
  307. * @ha: Pointer to host adapter structure.
  308. * @sts_entry: Pointer to status entry structure.
  309. **/
  310. static void qla4xxx_passthru_status_entry(struct scsi_qla_host *ha,
  311. struct passthru_status *sts_entry)
  312. {
  313. struct iscsi_task *task;
  314. struct ddb_entry *ddb_entry;
  315. struct ql4_task_data *task_data;
  316. struct iscsi_cls_conn *cls_conn;
  317. struct iscsi_conn *conn;
  318. itt_t itt;
  319. uint32_t fw_ddb_index;
  320. itt = sts_entry->handle;
  321. fw_ddb_index = le32_to_cpu(sts_entry->target);
  322. ddb_entry = qla4xxx_lookup_ddb_by_fw_index(ha, fw_ddb_index);
  323. if (ddb_entry == NULL) {
  324. ql4_printk(KERN_ERR, ha, "%s: Invalid target index = 0x%x\n",
  325. __func__, sts_entry->target);
  326. return;
  327. }
  328. cls_conn = ddb_entry->conn;
  329. conn = cls_conn->dd_data;
  330. spin_lock(&conn->session->back_lock);
  331. task = iscsi_itt_to_task(conn, itt);
  332. spin_unlock(&conn->session->back_lock);
  333. if (task == NULL) {
  334. ql4_printk(KERN_ERR, ha, "%s: Task is NULL\n", __func__);
  335. return;
  336. }
  337. task_data = task->dd_data;
  338. memcpy(&task_data->sts, sts_entry, sizeof(struct passthru_status));
  339. ha->iocb_cnt -= task_data->iocb_req_cnt;
  340. queue_work(ha->task_wq, &task_data->task_work);
  341. }
  342. static struct mrb *qla4xxx_del_mrb_from_active_array(struct scsi_qla_host *ha,
  343. uint32_t index)
  344. {
  345. struct mrb *mrb = NULL;
  346. /* validate handle and remove from active array */
  347. if (index >= MAX_MRB)
  348. return mrb;
  349. mrb = ha->active_mrb_array[index];
  350. ha->active_mrb_array[index] = NULL;
  351. if (!mrb)
  352. return mrb;
  353. /* update counters */
  354. ha->iocb_cnt -= mrb->iocb_cnt;
  355. return mrb;
  356. }
  357. static void qla4xxx_mbox_status_entry(struct scsi_qla_host *ha,
  358. struct mbox_status_iocb *mbox_sts_entry)
  359. {
  360. struct mrb *mrb;
  361. uint32_t status;
  362. uint32_t data_size;
  363. mrb = qla4xxx_del_mrb_from_active_array(ha,
  364. le32_to_cpu(mbox_sts_entry->handle));
  365. if (mrb == NULL) {
  366. ql4_printk(KERN_WARNING, ha, "%s: mrb[%d] is null\n", __func__,
  367. mbox_sts_entry->handle);
  368. return;
  369. }
  370. switch (mrb->mbox_cmd) {
  371. case MBOX_CMD_PING:
  372. DEBUG2(ql4_printk(KERN_INFO, ha, "%s: mbox_cmd = 0x%x, "
  373. "mbox_sts[0] = 0x%x, mbox_sts[6] = 0x%x\n",
  374. __func__, mrb->mbox_cmd,
  375. mbox_sts_entry->out_mbox[0],
  376. mbox_sts_entry->out_mbox[6]));
  377. if (mbox_sts_entry->out_mbox[0] == MBOX_STS_COMMAND_COMPLETE)
  378. status = ISCSI_PING_SUCCESS;
  379. else
  380. status = mbox_sts_entry->out_mbox[6];
  381. data_size = sizeof(mbox_sts_entry->out_mbox);
  382. qla4xxx_post_ping_evt_work(ha, status, mrb->pid, data_size,
  383. (uint8_t *) mbox_sts_entry->out_mbox);
  384. break;
  385. default:
  386. DEBUG2(ql4_printk(KERN_WARNING, ha, "%s: invalid mbox_cmd = "
  387. "0x%x\n", __func__, mrb->mbox_cmd));
  388. }
  389. kfree(mrb);
  390. return;
  391. }
  392. /**
  393. * qla4xxx_process_response_queue - process response queue completions
  394. * @ha: Pointer to host adapter structure.
  395. *
  396. * This routine process response queue completions in interrupt context.
  397. * Hardware_lock locked upon entry
  398. **/
  399. void qla4xxx_process_response_queue(struct scsi_qla_host *ha)
  400. {
  401. uint32_t count = 0;
  402. struct srb *srb = NULL;
  403. struct status_entry *sts_entry;
  404. /* Process all responses from response queue */
  405. while ((ha->response_ptr->signature != RESPONSE_PROCESSED)) {
  406. sts_entry = (struct status_entry *) ha->response_ptr;
  407. count++;
  408. /* Advance pointers for next entry */
  409. if (ha->response_out == (RESPONSE_QUEUE_DEPTH - 1)) {
  410. ha->response_out = 0;
  411. ha->response_ptr = ha->response_ring;
  412. } else {
  413. ha->response_out++;
  414. ha->response_ptr++;
  415. }
  416. /* process entry */
  417. switch (sts_entry->hdr.entryType) {
  418. case ET_STATUS:
  419. /* Common status */
  420. qla4xxx_status_entry(ha, sts_entry);
  421. break;
  422. case ET_PASSTHRU_STATUS:
  423. if (sts_entry->hdr.systemDefined == SD_ISCSI_PDU)
  424. qla4xxx_passthru_status_entry(ha,
  425. (struct passthru_status *)sts_entry);
  426. else
  427. ql4_printk(KERN_ERR, ha,
  428. "%s: Invalid status received\n",
  429. __func__);
  430. break;
  431. case ET_STATUS_CONTINUATION:
  432. qla4xxx_status_cont_entry(ha,
  433. (struct status_cont_entry *) sts_entry);
  434. break;
  435. case ET_COMMAND:
  436. /* ISP device queue is full. Command not
  437. * accepted by ISP. Queue command for
  438. * later */
  439. srb = qla4xxx_del_from_active_array(ha,
  440. le32_to_cpu(sts_entry->
  441. handle));
  442. if (srb == NULL)
  443. goto exit_prq_invalid_handle;
  444. DEBUG2(printk("scsi%ld: %s: FW device queue full, "
  445. "srb %p\n", ha->host_no, __func__, srb));
  446. /* ETRY normally by sending it back with
  447. * DID_BUS_BUSY */
  448. srb->cmd->result = DID_BUS_BUSY << 16;
  449. kref_put(&srb->srb_ref, qla4xxx_srb_compl);
  450. break;
  451. case ET_CONTINUE:
  452. /* Just throw away the continuation entries */
  453. DEBUG2(printk("scsi%ld: %s: Continuation entry - "
  454. "ignoring\n", ha->host_no, __func__));
  455. break;
  456. case ET_MBOX_STATUS:
  457. DEBUG2(ql4_printk(KERN_INFO, ha,
  458. "%s: mbox status IOCB\n", __func__));
  459. qla4xxx_mbox_status_entry(ha,
  460. (struct mbox_status_iocb *)sts_entry);
  461. break;
  462. default:
  463. /*
  464. * Invalid entry in response queue, reset RISC
  465. * firmware.
  466. */
  467. DEBUG2(printk("scsi%ld: %s: Invalid entry %x in "
  468. "response queue \n", ha->host_no,
  469. __func__,
  470. sts_entry->hdr.entryType));
  471. goto exit_prq_error;
  472. }
  473. ((struct response *)sts_entry)->signature = RESPONSE_PROCESSED;
  474. wmb();
  475. }
  476. /*
  477. * Tell ISP we're done with response(s). This also clears the interrupt.
  478. */
  479. ha->isp_ops->complete_iocb(ha);
  480. return;
  481. exit_prq_invalid_handle:
  482. DEBUG2(printk("scsi%ld: %s: Invalid handle(srb)=%p type=%x IOCS=%x\n",
  483. ha->host_no, __func__, srb, sts_entry->hdr.entryType,
  484. sts_entry->completionStatus));
  485. exit_prq_error:
  486. ha->isp_ops->complete_iocb(ha);
  487. set_bit(DPC_RESET_HA, &ha->dpc_flags);
  488. }
  489. /**
  490. * qla4_83xx_loopback_in_progress: Is loopback in progress?
  491. * @ha: Pointer to host adapter structure.
  492. * @ret: 1 = loopback in progress, 0 = loopback not in progress
  493. **/
  494. static int qla4_83xx_loopback_in_progress(struct scsi_qla_host *ha)
  495. {
  496. int rval = 1;
  497. if (is_qla8032(ha) || is_qla8042(ha)) {
  498. if ((ha->idc_info.info2 & ENABLE_INTERNAL_LOOPBACK) ||
  499. (ha->idc_info.info2 & ENABLE_EXTERNAL_LOOPBACK)) {
  500. DEBUG2(ql4_printk(KERN_INFO, ha,
  501. "%s: Loopback diagnostics in progress\n",
  502. __func__));
  503. rval = 1;
  504. } else {
  505. DEBUG2(ql4_printk(KERN_INFO, ha,
  506. "%s: Loopback diagnostics not in progress\n",
  507. __func__));
  508. rval = 0;
  509. }
  510. }
  511. return rval;
  512. }
  513. static void qla4xxx_update_ipaddr_state(struct scsi_qla_host *ha,
  514. uint32_t ipaddr_idx,
  515. uint32_t ipaddr_fw_state)
  516. {
  517. uint8_t ipaddr_state;
  518. uint8_t ip_idx;
  519. ip_idx = ipaddr_idx & 0xF;
  520. ipaddr_state = qla4xxx_set_ipaddr_state((uint8_t)ipaddr_fw_state);
  521. switch (ip_idx) {
  522. case 0:
  523. ha->ip_config.ipv4_addr_state = ipaddr_state;
  524. break;
  525. case 1:
  526. ha->ip_config.ipv6_link_local_state = ipaddr_state;
  527. break;
  528. case 2:
  529. ha->ip_config.ipv6_addr0_state = ipaddr_state;
  530. break;
  531. case 3:
  532. ha->ip_config.ipv6_addr1_state = ipaddr_state;
  533. break;
  534. default:
  535. ql4_printk(KERN_INFO, ha, "%s: Invalid IPADDR index %d\n",
  536. __func__, ip_idx);
  537. }
  538. }
  539. static void qla4xxx_default_router_changed(struct scsi_qla_host *ha,
  540. uint32_t *mbox_sts)
  541. {
  542. memcpy(&ha->ip_config.ipv6_default_router_addr.s6_addr32[0],
  543. &mbox_sts[2], sizeof(uint32_t));
  544. memcpy(&ha->ip_config.ipv6_default_router_addr.s6_addr32[1],
  545. &mbox_sts[3], sizeof(uint32_t));
  546. memcpy(&ha->ip_config.ipv6_default_router_addr.s6_addr32[2],
  547. &mbox_sts[4], sizeof(uint32_t));
  548. memcpy(&ha->ip_config.ipv6_default_router_addr.s6_addr32[3],
  549. &mbox_sts[5], sizeof(uint32_t));
  550. }
  551. /**
  552. * qla4xxx_isr_decode_mailbox - decodes mailbox status
  553. * @ha: Pointer to host adapter structure.
  554. * @mailbox_status: Mailbox status.
  555. *
  556. * This routine decodes the mailbox status during the ISR.
  557. * Hardware_lock locked upon entry. runs in interrupt context.
  558. **/
  559. static void qla4xxx_isr_decode_mailbox(struct scsi_qla_host * ha,
  560. uint32_t mbox_status)
  561. {
  562. int i;
  563. uint32_t mbox_sts[MBOX_AEN_REG_COUNT];
  564. __le32 __iomem *mailbox_out;
  565. uint32_t opcode = 0;
  566. if (is_qla8032(ha) || is_qla8042(ha))
  567. mailbox_out = &ha->qla4_83xx_reg->mailbox_out[0];
  568. else if (is_qla8022(ha))
  569. mailbox_out = &ha->qla4_82xx_reg->mailbox_out[0];
  570. else
  571. mailbox_out = &ha->reg->mailbox[0];
  572. if ((mbox_status == MBOX_STS_BUSY) ||
  573. (mbox_status == MBOX_STS_INTERMEDIATE_COMPLETION) ||
  574. (mbox_status >> 12 == MBOX_COMPLETION_STATUS)) {
  575. ha->mbox_status[0] = mbox_status;
  576. if (test_bit(AF_MBOX_COMMAND, &ha->flags)) {
  577. /*
  578. * Copy all mailbox registers to a temporary
  579. * location and set mailbox command done flag
  580. */
  581. for (i = 0; i < ha->mbox_status_count; i++)
  582. ha->mbox_status[i] = readl(&mailbox_out[i]);
  583. set_bit(AF_MBOX_COMMAND_DONE, &ha->flags);
  584. if (test_bit(AF_MBOX_COMMAND_NOPOLL, &ha->flags))
  585. complete(&ha->mbx_intr_comp);
  586. }
  587. } else if (mbox_status >> 12 == MBOX_ASYNC_EVENT_STATUS) {
  588. for (i = 0; i < MBOX_AEN_REG_COUNT; i++)
  589. mbox_sts[i] = readl(&mailbox_out[i]);
  590. /* Immediately process the AENs that don't require much work.
  591. * Only queue the database_changed AENs */
  592. if (ha->aen_log.count < MAX_AEN_ENTRIES) {
  593. for (i = 0; i < MBOX_AEN_REG_COUNT; i++)
  594. ha->aen_log.entry[ha->aen_log.count].mbox_sts[i] =
  595. mbox_sts[i];
  596. ha->aen_log.count++;
  597. }
  598. switch (mbox_status) {
  599. case MBOX_ASTS_SYSTEM_ERROR:
  600. /* Log Mailbox registers */
  601. ql4_printk(KERN_INFO, ha, "%s: System Err\n", __func__);
  602. qla4xxx_dump_registers(ha);
  603. if ((is_qla8022(ha) && ql4xdontresethba) ||
  604. ((is_qla8032(ha) || is_qla8042(ha)) &&
  605. qla4_83xx_idc_dontreset(ha))) {
  606. DEBUG2(printk("scsi%ld: %s:Don't Reset HBA\n",
  607. ha->host_no, __func__));
  608. } else {
  609. set_bit(AF_GET_CRASH_RECORD, &ha->flags);
  610. set_bit(DPC_RESET_HA, &ha->dpc_flags);
  611. }
  612. break;
  613. case MBOX_ASTS_REQUEST_TRANSFER_ERROR:
  614. case MBOX_ASTS_RESPONSE_TRANSFER_ERROR:
  615. case MBOX_ASTS_NVRAM_INVALID:
  616. case MBOX_ASTS_IP_ADDRESS_CHANGED:
  617. case MBOX_ASTS_DHCP_LEASE_EXPIRED:
  618. DEBUG2(printk("scsi%ld: AEN %04x, ERROR Status, "
  619. "Reset HA\n", ha->host_no, mbox_status));
  620. if (is_qla80XX(ha))
  621. set_bit(DPC_RESET_HA_FW_CONTEXT,
  622. &ha->dpc_flags);
  623. else
  624. set_bit(DPC_RESET_HA, &ha->dpc_flags);
  625. break;
  626. case MBOX_ASTS_LINK_UP:
  627. set_bit(AF_LINK_UP, &ha->flags);
  628. if (test_bit(AF_INIT_DONE, &ha->flags))
  629. set_bit(DPC_LINK_CHANGED, &ha->dpc_flags);
  630. ql4_printk(KERN_INFO, ha, "%s: LINK UP\n", __func__);
  631. qla4xxx_post_aen_work(ha, ISCSI_EVENT_LINKUP,
  632. sizeof(mbox_sts),
  633. (uint8_t *) mbox_sts);
  634. if ((is_qla8032(ha) || is_qla8042(ha)) &&
  635. ha->notify_link_up_comp)
  636. complete(&ha->link_up_comp);
  637. break;
  638. case MBOX_ASTS_LINK_DOWN:
  639. clear_bit(AF_LINK_UP, &ha->flags);
  640. if (test_bit(AF_INIT_DONE, &ha->flags)) {
  641. set_bit(DPC_LINK_CHANGED, &ha->dpc_flags);
  642. qla4xxx_wake_dpc(ha);
  643. }
  644. ql4_printk(KERN_INFO, ha, "%s: LINK DOWN\n", __func__);
  645. qla4xxx_post_aen_work(ha, ISCSI_EVENT_LINKDOWN,
  646. sizeof(mbox_sts),
  647. (uint8_t *) mbox_sts);
  648. break;
  649. case MBOX_ASTS_HEARTBEAT:
  650. ha->seconds_since_last_heartbeat = 0;
  651. break;
  652. case MBOX_ASTS_DHCP_LEASE_ACQUIRED:
  653. DEBUG2(printk("scsi%ld: AEN %04x DHCP LEASE "
  654. "ACQUIRED\n", ha->host_no, mbox_status));
  655. set_bit(DPC_GET_DHCP_IP_ADDR, &ha->dpc_flags);
  656. break;
  657. case MBOX_ASTS_PROTOCOL_STATISTIC_ALARM:
  658. case MBOX_ASTS_SCSI_COMMAND_PDU_REJECTED: /* Target
  659. * mode
  660. * only */
  661. case MBOX_ASTS_UNSOLICITED_PDU_RECEIVED: /* Connection mode */
  662. case MBOX_ASTS_IPSEC_SYSTEM_FATAL_ERROR:
  663. case MBOX_ASTS_SUBNET_STATE_CHANGE:
  664. case MBOX_ASTS_DUPLICATE_IP:
  665. /* No action */
  666. DEBUG2(printk("scsi%ld: AEN %04x\n", ha->host_no,
  667. mbox_status));
  668. break;
  669. case MBOX_ASTS_IP_ADDR_STATE_CHANGED:
  670. printk("scsi%ld: AEN %04x, mbox_sts[2]=%04x, "
  671. "mbox_sts[3]=%04x\n", ha->host_no, mbox_sts[0],
  672. mbox_sts[2], mbox_sts[3]);
  673. qla4xxx_update_ipaddr_state(ha, mbox_sts[5],
  674. mbox_sts[3]);
  675. /* mbox_sts[2] = Old ACB state
  676. * mbox_sts[3] = new ACB state */
  677. if ((mbox_sts[3] == IP_ADDRSTATE_PREFERRED) &&
  678. ((mbox_sts[2] == IP_ADDRSTATE_TENTATIVE) ||
  679. (mbox_sts[2] == IP_ADDRSTATE_ACQUIRING))) {
  680. set_bit(DPC_GET_DHCP_IP_ADDR, &ha->dpc_flags);
  681. } else if ((mbox_sts[3] == IP_ADDRSTATE_ACQUIRING) &&
  682. (mbox_sts[2] == IP_ADDRSTATE_PREFERRED)) {
  683. if (is_qla80XX(ha))
  684. set_bit(DPC_RESET_HA_FW_CONTEXT,
  685. &ha->dpc_flags);
  686. else
  687. set_bit(DPC_RESET_HA, &ha->dpc_flags);
  688. } else if (mbox_sts[3] == IP_ADDRSTATE_DISABLING) {
  689. ql4_printk(KERN_INFO, ha, "scsi%ld: %s: ACB in disabling state\n",
  690. ha->host_no, __func__);
  691. } else if (mbox_sts[3] == IP_ADDRSTATE_UNCONFIGURED) {
  692. complete(&ha->disable_acb_comp);
  693. ql4_printk(KERN_INFO, ha, "scsi%ld: %s: ACB state unconfigured\n",
  694. ha->host_no, __func__);
  695. }
  696. break;
  697. case MBOX_ASTS_IPV6_LINK_MTU_CHANGE:
  698. case MBOX_ASTS_IPV6_AUTO_PREFIX_IGNORED:
  699. case MBOX_ASTS_IPV6_ND_LOCAL_PREFIX_IGNORED:
  700. /* No action */
  701. DEBUG2(ql4_printk(KERN_INFO, ha, "scsi%ld: AEN %04x\n",
  702. ha->host_no, mbox_status));
  703. break;
  704. case MBOX_ASTS_ICMPV6_ERROR_MSG_RCVD:
  705. DEBUG2(ql4_printk(KERN_INFO, ha,
  706. "scsi%ld: AEN %04x, IPv6 ERROR, "
  707. "mbox_sts[1]=%08x, mbox_sts[2]=%08x, mbox_sts[3}=%08x, mbox_sts[4]=%08x mbox_sts[5]=%08x\n",
  708. ha->host_no, mbox_sts[0], mbox_sts[1],
  709. mbox_sts[2], mbox_sts[3], mbox_sts[4],
  710. mbox_sts[5]));
  711. break;
  712. case MBOX_ASTS_MAC_ADDRESS_CHANGED:
  713. case MBOX_ASTS_DNS:
  714. /* No action */
  715. DEBUG2(printk(KERN_INFO "scsi%ld: AEN %04x, "
  716. "mbox_sts[1]=%04x, mbox_sts[2]=%04x\n",
  717. ha->host_no, mbox_sts[0],
  718. mbox_sts[1], mbox_sts[2]));
  719. break;
  720. case MBOX_ASTS_SELF_TEST_FAILED:
  721. case MBOX_ASTS_LOGIN_FAILED:
  722. /* No action */
  723. DEBUG2(printk("scsi%ld: AEN %04x, mbox_sts[1]=%04x, "
  724. "mbox_sts[2]=%04x, mbox_sts[3]=%04x\n",
  725. ha->host_no, mbox_sts[0], mbox_sts[1],
  726. mbox_sts[2], mbox_sts[3]));
  727. break;
  728. case MBOX_ASTS_DATABASE_CHANGED:
  729. /* Queue AEN information and process it in the DPC
  730. * routine */
  731. if (ha->aen_q_count > 0) {
  732. /* decrement available counter */
  733. ha->aen_q_count--;
  734. for (i = 0; i < MBOX_AEN_REG_COUNT; i++)
  735. ha->aen_q[ha->aen_in].mbox_sts[i] =
  736. mbox_sts[i];
  737. /* print debug message */
  738. DEBUG2(printk("scsi%ld: AEN[%d] %04x queued "
  739. "mb1:0x%x mb2:0x%x mb3:0x%x "
  740. "mb4:0x%x mb5:0x%x\n",
  741. ha->host_no, ha->aen_in,
  742. mbox_sts[0], mbox_sts[1],
  743. mbox_sts[2], mbox_sts[3],
  744. mbox_sts[4], mbox_sts[5]));
  745. /* advance pointer */
  746. ha->aen_in++;
  747. if (ha->aen_in == MAX_AEN_ENTRIES)
  748. ha->aen_in = 0;
  749. /* The DPC routine will process the aen */
  750. set_bit(DPC_AEN, &ha->dpc_flags);
  751. } else {
  752. DEBUG2(printk("scsi%ld: %s: aen %04x, queue "
  753. "overflowed! AEN LOST!!\n",
  754. ha->host_no, __func__,
  755. mbox_sts[0]));
  756. DEBUG2(printk("scsi%ld: DUMP AEN QUEUE\n",
  757. ha->host_no));
  758. for (i = 0; i < MAX_AEN_ENTRIES; i++) {
  759. DEBUG2(printk("AEN[%d] %04x %04x %04x "
  760. "%04x\n", i, mbox_sts[0],
  761. mbox_sts[1], mbox_sts[2],
  762. mbox_sts[3]));
  763. }
  764. }
  765. break;
  766. case MBOX_ASTS_TXSCVR_INSERTED:
  767. DEBUG2(printk(KERN_WARNING
  768. "scsi%ld: AEN %04x Transceiver"
  769. " inserted\n", ha->host_no, mbox_sts[0]));
  770. break;
  771. case MBOX_ASTS_TXSCVR_REMOVED:
  772. DEBUG2(printk(KERN_WARNING
  773. "scsi%ld: AEN %04x Transceiver"
  774. " removed\n", ha->host_no, mbox_sts[0]));
  775. break;
  776. case MBOX_ASTS_IDC_REQUEST_NOTIFICATION:
  777. if (is_qla8032(ha) || is_qla8042(ha)) {
  778. DEBUG2(ql4_printk(KERN_INFO, ha,
  779. "scsi%ld: AEN %04x, mbox_sts[1]=%08x, mbox_sts[2]=%08x, mbox_sts[3]=%08x, mbox_sts[4]=%08x\n",
  780. ha->host_no, mbox_sts[0],
  781. mbox_sts[1], mbox_sts[2],
  782. mbox_sts[3], mbox_sts[4]));
  783. opcode = mbox_sts[1] >> 16;
  784. if ((opcode == MBOX_CMD_SET_PORT_CONFIG) ||
  785. (opcode == MBOX_CMD_PORT_RESET)) {
  786. set_bit(DPC_POST_IDC_ACK,
  787. &ha->dpc_flags);
  788. ha->idc_info.request_desc = mbox_sts[1];
  789. ha->idc_info.info1 = mbox_sts[2];
  790. ha->idc_info.info2 = mbox_sts[3];
  791. ha->idc_info.info3 = mbox_sts[4];
  792. qla4xxx_wake_dpc(ha);
  793. }
  794. }
  795. break;
  796. case MBOX_ASTS_IDC_COMPLETE:
  797. if (is_qla8032(ha) || is_qla8042(ha)) {
  798. DEBUG2(ql4_printk(KERN_INFO, ha,
  799. "scsi%ld: AEN %04x, mbox_sts[1]=%08x, mbox_sts[2]=%08x, mbox_sts[3]=%08x, mbox_sts[4]=%08x\n",
  800. ha->host_no, mbox_sts[0],
  801. mbox_sts[1], mbox_sts[2],
  802. mbox_sts[3], mbox_sts[4]));
  803. DEBUG2(ql4_printk(KERN_INFO, ha,
  804. "scsi:%ld: AEN %04x IDC Complete notification\n",
  805. ha->host_no, mbox_sts[0]));
  806. opcode = mbox_sts[1] >> 16;
  807. if (ha->notify_idc_comp)
  808. complete(&ha->idc_comp);
  809. if ((opcode == MBOX_CMD_SET_PORT_CONFIG) ||
  810. (opcode == MBOX_CMD_PORT_RESET))
  811. ha->idc_info.info2 = mbox_sts[3];
  812. if (qla4_83xx_loopback_in_progress(ha)) {
  813. set_bit(AF_LOOPBACK, &ha->flags);
  814. } else {
  815. clear_bit(AF_LOOPBACK, &ha->flags);
  816. if (ha->saved_acb)
  817. set_bit(DPC_RESTORE_ACB,
  818. &ha->dpc_flags);
  819. }
  820. qla4xxx_wake_dpc(ha);
  821. }
  822. break;
  823. case MBOX_ASTS_IPV6_DEFAULT_ROUTER_CHANGED:
  824. DEBUG2(ql4_printk(KERN_INFO, ha,
  825. "scsi%ld: AEN %04x, mbox_sts[1]=%08x, mbox_sts[2]=%08x, mbox_sts[3]=%08x, mbox_sts[4]=%08x mbox_sts[5]=%08x\n",
  826. ha->host_no, mbox_sts[0], mbox_sts[1],
  827. mbox_sts[2], mbox_sts[3], mbox_sts[4],
  828. mbox_sts[5]));
  829. DEBUG2(ql4_printk(KERN_INFO, ha,
  830. "scsi%ld: AEN %04x Received IPv6 default router changed notification\n",
  831. ha->host_no, mbox_sts[0]));
  832. qla4xxx_default_router_changed(ha, mbox_sts);
  833. break;
  834. case MBOX_ASTS_IDC_TIME_EXTEND_NOTIFICATION:
  835. DEBUG2(ql4_printk(KERN_INFO, ha,
  836. "scsi%ld: AEN %04x, mbox_sts[1]=%08x, mbox_sts[2]=%08x, mbox_sts[3]=%08x, mbox_sts[4]=%08x mbox_sts[5]=%08x\n",
  837. ha->host_no, mbox_sts[0], mbox_sts[1],
  838. mbox_sts[2], mbox_sts[3], mbox_sts[4],
  839. mbox_sts[5]));
  840. DEBUG2(ql4_printk(KERN_INFO, ha,
  841. "scsi%ld: AEN %04x Received IDC Extend Timeout notification\n",
  842. ha->host_no, mbox_sts[0]));
  843. /* new IDC timeout */
  844. ha->idc_extend_tmo = mbox_sts[1];
  845. break;
  846. case MBOX_ASTS_INITIALIZATION_FAILED:
  847. DEBUG2(ql4_printk(KERN_INFO, ha,
  848. "scsi%ld: AEN %04x, mbox_sts[3]=%08x\n",
  849. ha->host_no, mbox_sts[0],
  850. mbox_sts[3]));
  851. break;
  852. case MBOX_ASTS_SYSTEM_WARNING_EVENT:
  853. DEBUG2(ql4_printk(KERN_WARNING, ha,
  854. "scsi%ld: AEN %04x, mbox_sts[1]=%08x, mbox_sts[2]=%08x, mbox_sts[3]=%08x, mbox_sts[4]=%08x mbox_sts[5]=%08x\n",
  855. ha->host_no, mbox_sts[0], mbox_sts[1],
  856. mbox_sts[2], mbox_sts[3], mbox_sts[4],
  857. mbox_sts[5]));
  858. break;
  859. case MBOX_ASTS_DCBX_CONF_CHANGE:
  860. DEBUG2(ql4_printk(KERN_INFO, ha,
  861. "scsi%ld: AEN %04x, mbox_sts[1]=%08x, mbox_sts[2]=%08x, mbox_sts[3]=%08x, mbox_sts[4]=%08x mbox_sts[5]=%08x\n",
  862. ha->host_no, mbox_sts[0], mbox_sts[1],
  863. mbox_sts[2], mbox_sts[3], mbox_sts[4],
  864. mbox_sts[5]));
  865. DEBUG2(ql4_printk(KERN_INFO, ha,
  866. "scsi%ld: AEN %04x Received DCBX configuration changed notification\n",
  867. ha->host_no, mbox_sts[0]));
  868. break;
  869. default:
  870. DEBUG2(printk(KERN_WARNING
  871. "scsi%ld: AEN %04x UNKNOWN\n",
  872. ha->host_no, mbox_sts[0]));
  873. break;
  874. }
  875. } else {
  876. DEBUG2(printk("scsi%ld: Unknown mailbox status %08X\n",
  877. ha->host_no, mbox_status));
  878. ha->mbox_status[0] = mbox_status;
  879. }
  880. }
  881. void qla4_83xx_interrupt_service_routine(struct scsi_qla_host *ha,
  882. uint32_t intr_status)
  883. {
  884. /* Process mailbox/asynch event interrupt.*/
  885. if (intr_status) {
  886. qla4xxx_isr_decode_mailbox(ha,
  887. readl(&ha->qla4_83xx_reg->mailbox_out[0]));
  888. /* clear the interrupt */
  889. writel(0, &ha->qla4_83xx_reg->risc_intr);
  890. } else {
  891. qla4xxx_process_response_queue(ha);
  892. }
  893. /* clear the interrupt */
  894. writel(0, &ha->qla4_83xx_reg->mb_int_mask);
  895. }
  896. /**
  897. * qla4_82xx_interrupt_service_routine - isr
  898. * @ha: pointer to host adapter structure.
  899. *
  900. * This is the main interrupt service routine.
  901. * hardware_lock locked upon entry. runs in interrupt context.
  902. **/
  903. void qla4_82xx_interrupt_service_routine(struct scsi_qla_host *ha,
  904. uint32_t intr_status)
  905. {
  906. /* Process response queue interrupt. */
  907. if ((intr_status & HSRX_RISC_IOCB_INT) &&
  908. test_bit(AF_INIT_DONE, &ha->flags))
  909. qla4xxx_process_response_queue(ha);
  910. /* Process mailbox/asynch event interrupt.*/
  911. if (intr_status & HSRX_RISC_MB_INT)
  912. qla4xxx_isr_decode_mailbox(ha,
  913. readl(&ha->qla4_82xx_reg->mailbox_out[0]));
  914. /* clear the interrupt */
  915. writel(0, &ha->qla4_82xx_reg->host_int);
  916. readl(&ha->qla4_82xx_reg->host_int);
  917. }
  918. /**
  919. * qla4xxx_interrupt_service_routine - isr
  920. * @ha: pointer to host adapter structure.
  921. *
  922. * This is the main interrupt service routine.
  923. * hardware_lock locked upon entry. runs in interrupt context.
  924. **/
  925. void qla4xxx_interrupt_service_routine(struct scsi_qla_host * ha,
  926. uint32_t intr_status)
  927. {
  928. /* Process response queue interrupt. */
  929. if (intr_status & CSR_SCSI_COMPLETION_INTR)
  930. qla4xxx_process_response_queue(ha);
  931. /* Process mailbox/asynch event interrupt.*/
  932. if (intr_status & CSR_SCSI_PROCESSOR_INTR) {
  933. qla4xxx_isr_decode_mailbox(ha,
  934. readl(&ha->reg->mailbox[0]));
  935. /* Clear Mailbox Interrupt */
  936. writel(set_rmask(CSR_SCSI_PROCESSOR_INTR),
  937. &ha->reg->ctrl_status);
  938. readl(&ha->reg->ctrl_status);
  939. }
  940. }
  941. /**
  942. * qla4_82xx_spurious_interrupt - processes spurious interrupt
  943. * @ha: pointer to host adapter structure.
  944. * @reqs_count: .
  945. *
  946. **/
  947. static void qla4_82xx_spurious_interrupt(struct scsi_qla_host *ha,
  948. uint8_t reqs_count)
  949. {
  950. if (reqs_count)
  951. return;
  952. DEBUG2(ql4_printk(KERN_INFO, ha, "Spurious Interrupt\n"));
  953. if (is_qla8022(ha)) {
  954. writel(0, &ha->qla4_82xx_reg->host_int);
  955. if (test_bit(AF_INTx_ENABLED, &ha->flags))
  956. qla4_82xx_wr_32(ha, ha->nx_legacy_intr.tgt_mask_reg,
  957. 0xfbff);
  958. }
  959. ha->spurious_int_count++;
  960. }
  961. /**
  962. * qla4xxx_intr_handler - hardware interrupt handler.
  963. * @irq: Unused
  964. * @dev_id: Pointer to host adapter structure
  965. **/
  966. irqreturn_t qla4xxx_intr_handler(int irq, void *dev_id)
  967. {
  968. struct scsi_qla_host *ha;
  969. uint32_t intr_status;
  970. unsigned long flags = 0;
  971. uint8_t reqs_count = 0;
  972. ha = (struct scsi_qla_host *) dev_id;
  973. if (!ha) {
  974. DEBUG2(printk(KERN_INFO
  975. "qla4xxx: Interrupt with NULL host ptr\n"));
  976. return IRQ_NONE;
  977. }
  978. spin_lock_irqsave(&ha->hardware_lock, flags);
  979. ha->isr_count++;
  980. /*
  981. * Repeatedly service interrupts up to a maximum of
  982. * MAX_REQS_SERVICED_PER_INTR
  983. */
  984. while (1) {
  985. /*
  986. * Read interrupt status
  987. */
  988. if (ha->isp_ops->rd_shdw_rsp_q_in(ha) !=
  989. ha->response_out)
  990. intr_status = CSR_SCSI_COMPLETION_INTR;
  991. else
  992. intr_status = readl(&ha->reg->ctrl_status);
  993. if ((intr_status &
  994. (CSR_SCSI_RESET_INTR|CSR_FATAL_ERROR|INTR_PENDING)) == 0) {
  995. if (reqs_count == 0)
  996. ha->spurious_int_count++;
  997. break;
  998. }
  999. if (intr_status & CSR_FATAL_ERROR) {
  1000. DEBUG2(printk(KERN_INFO "scsi%ld: Fatal Error, "
  1001. "Status 0x%04x\n", ha->host_no,
  1002. readl(isp_port_error_status (ha))));
  1003. /* Issue Soft Reset to clear this error condition.
  1004. * This will prevent the RISC from repeatedly
  1005. * interrupting the driver; thus, allowing the DPC to
  1006. * get scheduled to continue error recovery.
  1007. * NOTE: Disabling RISC interrupts does not work in
  1008. * this case, as CSR_FATAL_ERROR overrides
  1009. * CSR_SCSI_INTR_ENABLE */
  1010. if ((readl(&ha->reg->ctrl_status) &
  1011. CSR_SCSI_RESET_INTR) == 0) {
  1012. writel(set_rmask(CSR_SOFT_RESET),
  1013. &ha->reg->ctrl_status);
  1014. readl(&ha->reg->ctrl_status);
  1015. }
  1016. writel(set_rmask(CSR_FATAL_ERROR),
  1017. &ha->reg->ctrl_status);
  1018. readl(&ha->reg->ctrl_status);
  1019. __qla4xxx_disable_intrs(ha);
  1020. set_bit(DPC_RESET_HA, &ha->dpc_flags);
  1021. break;
  1022. } else if (intr_status & CSR_SCSI_RESET_INTR) {
  1023. clear_bit(AF_ONLINE, &ha->flags);
  1024. __qla4xxx_disable_intrs(ha);
  1025. writel(set_rmask(CSR_SCSI_RESET_INTR),
  1026. &ha->reg->ctrl_status);
  1027. readl(&ha->reg->ctrl_status);
  1028. if (!test_bit(AF_HA_REMOVAL, &ha->flags))
  1029. set_bit(DPC_RESET_HA_INTR, &ha->dpc_flags);
  1030. break;
  1031. } else if (intr_status & INTR_PENDING) {
  1032. ha->isp_ops->interrupt_service_routine(ha, intr_status);
  1033. ha->total_io_count++;
  1034. if (++reqs_count == MAX_REQS_SERVICED_PER_INTR)
  1035. break;
  1036. }
  1037. }
  1038. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  1039. return IRQ_HANDLED;
  1040. }
  1041. /**
  1042. * qla4_82xx_intr_handler - hardware interrupt handler.
  1043. * @irq: Unused
  1044. * @dev_id: Pointer to host adapter structure
  1045. **/
  1046. irqreturn_t qla4_82xx_intr_handler(int irq, void *dev_id)
  1047. {
  1048. struct scsi_qla_host *ha = dev_id;
  1049. uint32_t intr_status;
  1050. uint32_t status;
  1051. unsigned long flags = 0;
  1052. uint8_t reqs_count = 0;
  1053. if (unlikely(pci_channel_offline(ha->pdev)))
  1054. return IRQ_HANDLED;
  1055. ha->isr_count++;
  1056. status = qla4_82xx_rd_32(ha, ISR_INT_VECTOR);
  1057. if (!(status & ha->nx_legacy_intr.int_vec_bit))
  1058. return IRQ_NONE;
  1059. status = qla4_82xx_rd_32(ha, ISR_INT_STATE_REG);
  1060. if (!ISR_IS_LEGACY_INTR_TRIGGERED(status)) {
  1061. DEBUG7(ql4_printk(KERN_INFO, ha,
  1062. "%s legacy Int not triggered\n", __func__));
  1063. return IRQ_NONE;
  1064. }
  1065. /* clear the interrupt */
  1066. qla4_82xx_wr_32(ha, ha->nx_legacy_intr.tgt_status_reg, 0xffffffff);
  1067. /* read twice to ensure write is flushed */
  1068. qla4_82xx_rd_32(ha, ISR_INT_VECTOR);
  1069. qla4_82xx_rd_32(ha, ISR_INT_VECTOR);
  1070. spin_lock_irqsave(&ha->hardware_lock, flags);
  1071. while (1) {
  1072. if (!(readl(&ha->qla4_82xx_reg->host_int) &
  1073. ISRX_82XX_RISC_INT)) {
  1074. qla4_82xx_spurious_interrupt(ha, reqs_count);
  1075. break;
  1076. }
  1077. intr_status = readl(&ha->qla4_82xx_reg->host_status);
  1078. if ((intr_status &
  1079. (HSRX_RISC_MB_INT | HSRX_RISC_IOCB_INT)) == 0) {
  1080. qla4_82xx_spurious_interrupt(ha, reqs_count);
  1081. break;
  1082. }
  1083. ha->isp_ops->interrupt_service_routine(ha, intr_status);
  1084. /* Enable Interrupt */
  1085. qla4_82xx_wr_32(ha, ha->nx_legacy_intr.tgt_mask_reg, 0xfbff);
  1086. if (++reqs_count == MAX_REQS_SERVICED_PER_INTR)
  1087. break;
  1088. }
  1089. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  1090. return IRQ_HANDLED;
  1091. }
  1092. #define LEG_INT_PTR_B31 (1 << 31)
  1093. #define LEG_INT_PTR_B30 (1 << 30)
  1094. #define PF_BITS_MASK (0xF << 16)
  1095. /**
  1096. * qla4_83xx_intr_handler - hardware interrupt handler.
  1097. * @irq: Unused
  1098. * @dev_id: Pointer to host adapter structure
  1099. **/
  1100. irqreturn_t qla4_83xx_intr_handler(int irq, void *dev_id)
  1101. {
  1102. struct scsi_qla_host *ha = dev_id;
  1103. uint32_t leg_int_ptr = 0;
  1104. unsigned long flags = 0;
  1105. ha->isr_count++;
  1106. leg_int_ptr = readl(&ha->qla4_83xx_reg->leg_int_ptr);
  1107. /* Legacy interrupt is valid if bit31 of leg_int_ptr is set */
  1108. if (!(leg_int_ptr & LEG_INT_PTR_B31)) {
  1109. DEBUG7(ql4_printk(KERN_ERR, ha,
  1110. "%s: Legacy Interrupt Bit 31 not set, spurious interrupt!\n",
  1111. __func__));
  1112. return IRQ_NONE;
  1113. }
  1114. /* Validate the PCIE function ID set in leg_int_ptr bits [19..16] */
  1115. if ((leg_int_ptr & PF_BITS_MASK) != ha->pf_bit) {
  1116. DEBUG7(ql4_printk(KERN_ERR, ha,
  1117. "%s: Incorrect function ID 0x%x in legacy interrupt register, ha->pf_bit = 0x%x\n",
  1118. __func__, (leg_int_ptr & PF_BITS_MASK),
  1119. ha->pf_bit));
  1120. return IRQ_NONE;
  1121. }
  1122. /* To de-assert legacy interrupt, write 0 to Legacy Interrupt Trigger
  1123. * Control register and poll till Legacy Interrupt Pointer register
  1124. * bit30 is 0.
  1125. */
  1126. writel(0, &ha->qla4_83xx_reg->leg_int_trig);
  1127. do {
  1128. leg_int_ptr = readl(&ha->qla4_83xx_reg->leg_int_ptr);
  1129. if ((leg_int_ptr & PF_BITS_MASK) != ha->pf_bit)
  1130. break;
  1131. } while (leg_int_ptr & LEG_INT_PTR_B30);
  1132. spin_lock_irqsave(&ha->hardware_lock, flags);
  1133. leg_int_ptr = readl(&ha->qla4_83xx_reg->risc_intr);
  1134. ha->isp_ops->interrupt_service_routine(ha, leg_int_ptr);
  1135. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  1136. return IRQ_HANDLED;
  1137. }
  1138. irqreturn_t
  1139. qla4_8xxx_msi_handler(int irq, void *dev_id)
  1140. {
  1141. struct scsi_qla_host *ha;
  1142. ha = (struct scsi_qla_host *) dev_id;
  1143. if (!ha) {
  1144. DEBUG2(printk(KERN_INFO
  1145. "qla4xxx: MSIX: Interrupt with NULL host ptr\n"));
  1146. return IRQ_NONE;
  1147. }
  1148. ha->isr_count++;
  1149. /* clear the interrupt */
  1150. qla4_82xx_wr_32(ha, ha->nx_legacy_intr.tgt_status_reg, 0xffffffff);
  1151. /* read twice to ensure write is flushed */
  1152. qla4_82xx_rd_32(ha, ISR_INT_VECTOR);
  1153. qla4_82xx_rd_32(ha, ISR_INT_VECTOR);
  1154. return qla4_8xxx_default_intr_handler(irq, dev_id);
  1155. }
  1156. static irqreturn_t qla4_83xx_mailbox_intr_handler(int irq, void *dev_id)
  1157. {
  1158. struct scsi_qla_host *ha = dev_id;
  1159. unsigned long flags;
  1160. uint32_t ival = 0;
  1161. spin_lock_irqsave(&ha->hardware_lock, flags);
  1162. ival = readl(&ha->qla4_83xx_reg->risc_intr);
  1163. if (ival == 0) {
  1164. ql4_printk(KERN_INFO, ha,
  1165. "%s: It is a spurious mailbox interrupt!\n",
  1166. __func__);
  1167. ival = readl(&ha->qla4_83xx_reg->mb_int_mask);
  1168. ival &= ~INT_MASK_FW_MB;
  1169. writel(ival, &ha->qla4_83xx_reg->mb_int_mask);
  1170. goto exit;
  1171. }
  1172. qla4xxx_isr_decode_mailbox(ha,
  1173. readl(&ha->qla4_83xx_reg->mailbox_out[0]));
  1174. writel(0, &ha->qla4_83xx_reg->risc_intr);
  1175. ival = readl(&ha->qla4_83xx_reg->mb_int_mask);
  1176. ival &= ~INT_MASK_FW_MB;
  1177. writel(ival, &ha->qla4_83xx_reg->mb_int_mask);
  1178. ha->isr_count++;
  1179. exit:
  1180. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  1181. return IRQ_HANDLED;
  1182. }
  1183. /**
  1184. * qla4_8xxx_default_intr_handler - hardware interrupt handler.
  1185. * @irq: Unused
  1186. * @dev_id: Pointer to host adapter structure
  1187. *
  1188. * This interrupt handler is called directly for MSI-X, and
  1189. * called indirectly for MSI.
  1190. **/
  1191. irqreturn_t
  1192. qla4_8xxx_default_intr_handler(int irq, void *dev_id)
  1193. {
  1194. struct scsi_qla_host *ha = dev_id;
  1195. unsigned long flags;
  1196. uint32_t intr_status;
  1197. uint8_t reqs_count = 0;
  1198. if (is_qla8032(ha) || is_qla8042(ha)) {
  1199. qla4_83xx_mailbox_intr_handler(irq, dev_id);
  1200. } else {
  1201. spin_lock_irqsave(&ha->hardware_lock, flags);
  1202. while (1) {
  1203. if (!(readl(&ha->qla4_82xx_reg->host_int) &
  1204. ISRX_82XX_RISC_INT)) {
  1205. qla4_82xx_spurious_interrupt(ha, reqs_count);
  1206. break;
  1207. }
  1208. intr_status = readl(&ha->qla4_82xx_reg->host_status);
  1209. if ((intr_status &
  1210. (HSRX_RISC_MB_INT | HSRX_RISC_IOCB_INT)) == 0) {
  1211. qla4_82xx_spurious_interrupt(ha, reqs_count);
  1212. break;
  1213. }
  1214. ha->isp_ops->interrupt_service_routine(ha, intr_status);
  1215. if (++reqs_count == MAX_REQS_SERVICED_PER_INTR)
  1216. break;
  1217. }
  1218. ha->isr_count++;
  1219. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  1220. }
  1221. return IRQ_HANDLED;
  1222. }
  1223. irqreturn_t
  1224. qla4_8xxx_msix_rsp_q(int irq, void *dev_id)
  1225. {
  1226. struct scsi_qla_host *ha = dev_id;
  1227. unsigned long flags;
  1228. int intr_status;
  1229. uint32_t ival = 0;
  1230. spin_lock_irqsave(&ha->hardware_lock, flags);
  1231. if (is_qla8032(ha) || is_qla8042(ha)) {
  1232. ival = readl(&ha->qla4_83xx_reg->iocb_int_mask);
  1233. if (ival == 0) {
  1234. ql4_printk(KERN_INFO, ha, "%s: It is a spurious iocb interrupt!\n",
  1235. __func__);
  1236. goto exit_msix_rsp_q;
  1237. }
  1238. qla4xxx_process_response_queue(ha);
  1239. writel(0, &ha->qla4_83xx_reg->iocb_int_mask);
  1240. } else {
  1241. intr_status = readl(&ha->qla4_82xx_reg->host_status);
  1242. if (intr_status & HSRX_RISC_IOCB_INT) {
  1243. qla4xxx_process_response_queue(ha);
  1244. writel(0, &ha->qla4_82xx_reg->host_int);
  1245. } else {
  1246. ql4_printk(KERN_INFO, ha, "%s: spurious iocb interrupt...\n",
  1247. __func__);
  1248. goto exit_msix_rsp_q;
  1249. }
  1250. }
  1251. ha->isr_count++;
  1252. exit_msix_rsp_q:
  1253. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  1254. return IRQ_HANDLED;
  1255. }
  1256. /**
  1257. * qla4xxx_process_aen - processes AENs generated by firmware
  1258. * @ha: pointer to host adapter structure.
  1259. * @process_aen: type of AENs to process
  1260. *
  1261. * Processes specific types of Asynchronous Events generated by firmware.
  1262. * The type of AENs to process is specified by process_aen and can be
  1263. * PROCESS_ALL_AENS 0
  1264. * FLUSH_DDB_CHANGED_AENS 1
  1265. * RELOGIN_DDB_CHANGED_AENS 2
  1266. **/
  1267. void qla4xxx_process_aen(struct scsi_qla_host * ha, uint8_t process_aen)
  1268. {
  1269. uint32_t mbox_sts[MBOX_AEN_REG_COUNT];
  1270. struct aen *aen;
  1271. int i;
  1272. unsigned long flags;
  1273. spin_lock_irqsave(&ha->hardware_lock, flags);
  1274. while (ha->aen_out != ha->aen_in) {
  1275. aen = &ha->aen_q[ha->aen_out];
  1276. /* copy aen information to local structure */
  1277. for (i = 0; i < MBOX_AEN_REG_COUNT; i++)
  1278. mbox_sts[i] = aen->mbox_sts[i];
  1279. ha->aen_q_count++;
  1280. ha->aen_out++;
  1281. if (ha->aen_out == MAX_AEN_ENTRIES)
  1282. ha->aen_out = 0;
  1283. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  1284. DEBUG2(printk("qla4xxx(%ld): AEN[%d]=0x%08x, mbx1=0x%08x mbx2=0x%08x"
  1285. " mbx3=0x%08x mbx4=0x%08x\n", ha->host_no,
  1286. (ha->aen_out ? (ha->aen_out-1): (MAX_AEN_ENTRIES-1)),
  1287. mbox_sts[0], mbox_sts[1], mbox_sts[2],
  1288. mbox_sts[3], mbox_sts[4]));
  1289. switch (mbox_sts[0]) {
  1290. case MBOX_ASTS_DATABASE_CHANGED:
  1291. switch (process_aen) {
  1292. case FLUSH_DDB_CHANGED_AENS:
  1293. DEBUG2(printk("scsi%ld: AEN[%d] %04x, index "
  1294. "[%d] state=%04x FLUSHED!\n",
  1295. ha->host_no, ha->aen_out,
  1296. mbox_sts[0], mbox_sts[2],
  1297. mbox_sts[3]));
  1298. break;
  1299. case PROCESS_ALL_AENS:
  1300. default:
  1301. /* Specific device. */
  1302. if (mbox_sts[1] == 1)
  1303. qla4xxx_process_ddb_changed(ha,
  1304. mbox_sts[2], mbox_sts[3],
  1305. mbox_sts[4]);
  1306. break;
  1307. }
  1308. }
  1309. spin_lock_irqsave(&ha->hardware_lock, flags);
  1310. }
  1311. spin_unlock_irqrestore(&ha->hardware_lock, flags);
  1312. }
  1313. int qla4xxx_request_irqs(struct scsi_qla_host *ha)
  1314. {
  1315. int ret = 0;
  1316. int rval = QLA_ERROR;
  1317. if (is_qla40XX(ha))
  1318. goto try_intx;
  1319. if (ql4xenablemsix == 2) {
  1320. /* Note: MSI Interrupts not supported for ISP8324 and ISP8042 */
  1321. if (is_qla8032(ha) || is_qla8042(ha)) {
  1322. ql4_printk(KERN_INFO, ha, "%s: MSI Interrupts not supported for ISP%04x, Falling back-to INTx mode\n",
  1323. __func__, ha->pdev->device);
  1324. goto try_intx;
  1325. }
  1326. goto try_msi;
  1327. }
  1328. if (ql4xenablemsix == 0 || ql4xenablemsix != 1)
  1329. goto try_intx;
  1330. /* Trying MSI-X */
  1331. ret = qla4_8xxx_enable_msix(ha);
  1332. if (!ret) {
  1333. DEBUG2(ql4_printk(KERN_INFO, ha,
  1334. "MSI-X: Enabled (0x%X).\n", ha->revision_id));
  1335. goto irq_attached;
  1336. } else {
  1337. if (is_qla8032(ha) || is_qla8042(ha)) {
  1338. ql4_printk(KERN_INFO, ha, "%s: ISP%04x: MSI-X: Falling back-to INTx mode. ret = %d\n",
  1339. __func__, ha->pdev->device, ret);
  1340. goto try_intx;
  1341. }
  1342. }
  1343. ql4_printk(KERN_WARNING, ha,
  1344. "MSI-X: Falling back-to MSI mode -- %d.\n", ret);
  1345. try_msi:
  1346. /* Trying MSI */
  1347. ret = pci_enable_msi(ha->pdev);
  1348. if (!ret) {
  1349. ret = request_irq(ha->pdev->irq, qla4_8xxx_msi_handler,
  1350. 0, DRIVER_NAME, ha);
  1351. if (!ret) {
  1352. DEBUG2(ql4_printk(KERN_INFO, ha, "MSI: Enabled.\n"));
  1353. set_bit(AF_MSI_ENABLED, &ha->flags);
  1354. goto irq_attached;
  1355. } else {
  1356. ql4_printk(KERN_WARNING, ha,
  1357. "MSI: Failed to reserve interrupt %d "
  1358. "already in use.\n", ha->pdev->irq);
  1359. pci_disable_msi(ha->pdev);
  1360. }
  1361. }
  1362. try_intx:
  1363. if (is_qla8022(ha)) {
  1364. ql4_printk(KERN_WARNING, ha, "%s: ISP82xx Legacy interrupt not supported\n",
  1365. __func__);
  1366. goto irq_not_attached;
  1367. }
  1368. /* Trying INTx */
  1369. ret = request_irq(ha->pdev->irq, ha->isp_ops->intr_handler,
  1370. IRQF_SHARED, DRIVER_NAME, ha);
  1371. if (!ret) {
  1372. DEBUG2(ql4_printk(KERN_INFO, ha, "INTx: Enabled.\n"));
  1373. set_bit(AF_INTx_ENABLED, &ha->flags);
  1374. goto irq_attached;
  1375. } else {
  1376. ql4_printk(KERN_WARNING, ha,
  1377. "INTx: Failed to reserve interrupt %d already in"
  1378. " use.\n", ha->pdev->irq);
  1379. goto irq_not_attached;
  1380. }
  1381. irq_attached:
  1382. set_bit(AF_IRQ_ATTACHED, &ha->flags);
  1383. ha->host->irq = ha->pdev->irq;
  1384. ql4_printk(KERN_INFO, ha, "%s: irq %d attached\n",
  1385. __func__, ha->pdev->irq);
  1386. rval = QLA_SUCCESS;
  1387. irq_not_attached:
  1388. return rval;
  1389. }
  1390. void qla4xxx_free_irqs(struct scsi_qla_host *ha)
  1391. {
  1392. if (test_and_clear_bit(AF_IRQ_ATTACHED, &ha->flags)) {
  1393. if (test_bit(AF_MSIX_ENABLED, &ha->flags)) {
  1394. qla4_8xxx_disable_msix(ha);
  1395. } else if (test_and_clear_bit(AF_MSI_ENABLED, &ha->flags)) {
  1396. free_irq(ha->pdev->irq, ha);
  1397. pci_disable_msi(ha->pdev);
  1398. } else if (test_and_clear_bit(AF_INTx_ENABLED, &ha->flags)) {
  1399. free_irq(ha->pdev->irq, ha);
  1400. }
  1401. }
  1402. }