Lines Matching +full:- +full:a +full:-

5  *  Copyright (c) 2001-2013 ATTO Technology, Inc.
8 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
23 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
39 * You should have received a copy of the GNU General Public License
41 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
43 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
48 static void esas2r_doorbell_interrupt(struct esas2r_adapter *a, u32 doorbell);
49 static void esas2r_get_outbound_responses(struct esas2r_adapter *a);
50 static void esas2r_process_bus_reset(struct esas2r_adapter *a);
56 void esas2r_polled_interrupt(struct esas2r_adapter *a) in esas2r_polled_interrupt() argument
61 esas2r_disable_chip_interrupts(a); in esas2r_polled_interrupt()
63 intstat = esas2r_read_register_dword(a, MU_INT_STATUS_OUT); in esas2r_polled_interrupt()
68 esas2r_write_register_dword(a, MU_OUT_LIST_INT_STAT, in esas2r_polled_interrupt()
70 esas2r_flush_register_dword(a, MU_OUT_LIST_INT_STAT); in esas2r_polled_interrupt()
72 esas2r_get_outbound_responses(a); in esas2r_polled_interrupt()
76 doorbell = esas2r_read_register_dword(a, MU_DOORBELL_OUT); in esas2r_polled_interrupt()
78 esas2r_doorbell_interrupt(a, doorbell); in esas2r_polled_interrupt()
81 esas2r_enable_chip_interrupts(a); in esas2r_polled_interrupt()
83 if (atomic_read(&a->disable_cnt) == 0) in esas2r_polled_interrupt()
84 esas2r_do_deferred_processes(a); in esas2r_polled_interrupt()
89 * schedules a TASKLET to process events, whereas the MSI handler just
94 struct esas2r_adapter *a = (struct esas2r_adapter *)dev_id; in esas2r_interrupt() local
96 if (!esas2r_adapter_interrupt_pending(a)) in esas2r_interrupt()
99 set_bit(AF2_INT_PENDING, &a->flags2); in esas2r_interrupt()
100 esas2r_schedule_tasklet(a); in esas2r_interrupt()
105 void esas2r_adapter_interrupt(struct esas2r_adapter *a) in esas2r_adapter_interrupt() argument
109 if (likely(a->int_stat & MU_INTSTAT_POST_OUT)) { in esas2r_adapter_interrupt()
111 esas2r_write_register_dword(a, MU_OUT_LIST_INT_STAT, in esas2r_adapter_interrupt()
113 esas2r_flush_register_dword(a, MU_OUT_LIST_INT_STAT); in esas2r_adapter_interrupt()
114 esas2r_get_outbound_responses(a); in esas2r_adapter_interrupt()
117 if (unlikely(a->int_stat & MU_INTSTAT_DRBL)) { in esas2r_adapter_interrupt()
118 doorbell = esas2r_read_register_dword(a, MU_DOORBELL_OUT); in esas2r_adapter_interrupt()
120 esas2r_doorbell_interrupt(a, doorbell); in esas2r_adapter_interrupt()
123 a->int_mask = ESAS2R_INT_STS_MASK; in esas2r_adapter_interrupt()
125 esas2r_enable_chip_interrupts(a); in esas2r_adapter_interrupt()
127 if (likely(atomic_read(&a->disable_cnt) == 0)) in esas2r_adapter_interrupt()
128 esas2r_do_deferred_processes(a); in esas2r_adapter_interrupt()
133 struct esas2r_adapter *a = (struct esas2r_adapter *)dev_id; in esas2r_msi_interrupt() local
137 intstat = esas2r_read_register_dword(a, MU_INT_STATUS_OUT); in esas2r_msi_interrupt()
142 esas2r_write_register_dword(a, MU_OUT_LIST_INT_STAT, in esas2r_msi_interrupt()
144 esas2r_flush_register_dword(a, MU_OUT_LIST_INT_STAT); in esas2r_msi_interrupt()
146 esas2r_get_outbound_responses(a); in esas2r_msi_interrupt()
150 doorbell = esas2r_read_register_dword(a, MU_DOORBELL_OUT); in esas2r_msi_interrupt()
152 esas2r_doorbell_interrupt(a, doorbell); in esas2r_msi_interrupt()
156 * Work around a chip bug and force a new MSI to be sent if one is in esas2r_msi_interrupt()
159 esas2r_disable_chip_interrupts(a); in esas2r_msi_interrupt()
160 esas2r_enable_chip_interrupts(a); in esas2r_msi_interrupt()
162 if (likely(atomic_read(&a->disable_cnt) == 0)) in esas2r_msi_interrupt()
163 esas2r_do_deferred_processes(a); in esas2r_msi_interrupt()
165 esas2r_do_tasklet_tasks(a); in esas2r_msi_interrupt()
172 static void esas2r_handle_outbound_rsp_err(struct esas2r_adapter *a, in esas2r_handle_outbound_rsp_err() argument
179 * occurred and setup a callback to do error processing. in esas2r_handle_outbound_rsp_err()
181 if (unlikely(rq->req_stat != RS_SUCCESS)) { in esas2r_handle_outbound_rsp_err()
182 memcpy(&rq->func_rsp, &rsp->func_rsp, sizeof(rsp->func_rsp)); in esas2r_handle_outbound_rsp_err()
184 if (rq->req_stat == RS_ABORTED) { in esas2r_handle_outbound_rsp_err()
185 if (rq->timeout > RQ_MAX_TIMEOUT) in esas2r_handle_outbound_rsp_err()
186 rq->req_stat = RS_TIMEOUT; in esas2r_handle_outbound_rsp_err()
187 } else if (rq->req_stat == RS_SCSI_ERROR) { in esas2r_handle_outbound_rsp_err()
188 u8 scsistatus = rq->func_rsp.scsi_rsp.scsi_stat; in esas2r_handle_outbound_rsp_err()
192 /* Any of these are a good result. */ in esas2r_handle_outbound_rsp_err()
197 rq->req_stat = RS_SUCCESS; in esas2r_handle_outbound_rsp_err()
198 rq->func_rsp.scsi_rsp.scsi_stat = in esas2r_handle_outbound_rsp_err()
205 static void esas2r_get_outbound_responses(struct esas2r_adapter *a) in esas2r_get_outbound_responses() argument
218 spin_lock_irqsave(&a->queue_lock, flags); in esas2r_get_outbound_responses()
221 rspput_ptr = le32_to_cpu(*a->outbound_copy) & MU_OLC_WRT_PTR; in esas2r_get_outbound_responses()
222 rspget_ptr = a->last_read; in esas2r_get_outbound_responses()
228 spin_unlock_irqrestore(&a->queue_lock, flags); in esas2r_get_outbound_responses()
234 if (unlikely(rspput_ptr >= a->list_size)) { in esas2r_get_outbound_responses()
235 spin_unlock_irqrestore(&a->queue_lock, flags); in esas2r_get_outbound_responses()
237 esas2r_local_reset_adapter(a); in esas2r_get_outbound_responses()
245 if (rspget_ptr >= a->list_size) in esas2r_get_outbound_responses()
248 rsp = (struct atto_vda_ob_rsp *)a->outbound_list_md.virt_addr in esas2r_get_outbound_responses()
251 handle = rsp->handle; in esas2r_get_outbound_responses()
262 rq = a->req_table[LOWORD(handle)]; in esas2r_get_outbound_responses()
264 if (unlikely(rq == NULL || rq->vrq->scsi.handle != handle)) { in esas2r_get_outbound_responses()
269 list_del(&rq->req_list); in esas2r_get_outbound_responses()
272 rq->req_stat = rsp->req_stat; in esas2r_get_outbound_responses()
276 esas2r_trace("req_status: %x", rq->req_stat); in esas2r_get_outbound_responses()
278 if (likely(rq->vrq->scsi.function == VDA_FUNC_SCSI)) { in esas2r_get_outbound_responses()
279 esas2r_handle_outbound_rsp_err(a, rq, rsp); in esas2r_get_outbound_responses()
282 * Copy the outbound completion struct for non-I/O in esas2r_get_outbound_responses()
285 memcpy(&rq->func_rsp, &rsp->func_rsp, in esas2r_get_outbound_responses()
286 sizeof(rsp->func_rsp)); in esas2r_get_outbound_responses()
290 list_add_tail(&rq->comp_list, &comp_list); in esas2r_get_outbound_responses()
294 a->last_read = rspget_ptr; in esas2r_get_outbound_responses()
295 spin_unlock_irqrestore(&a->queue_lock, flags); in esas2r_get_outbound_responses()
297 esas2r_comp_list_drain(a, &comp_list); in esas2r_get_outbound_responses()
306 void esas2r_do_deferred_processes(struct esas2r_adapter *a) in esas2r_do_deferred_processes() argument
315 * = 0 - do not start any requests in esas2r_do_deferred_processes()
316 * = 1 - can start discovery requests in esas2r_do_deferred_processes()
317 * = 2 - can start any request in esas2r_do_deferred_processes()
320 if (test_bit(AF_CHPRST_PENDING, &a->flags) || in esas2r_do_deferred_processes()
321 test_bit(AF_FLASHING, &a->flags)) in esas2r_do_deferred_processes()
323 else if (test_bit(AF_DISC_PENDING, &a->flags)) in esas2r_do_deferred_processes()
326 atomic_inc(&a->disable_cnt); in esas2r_do_deferred_processes()
330 if (esas2r_is_tasklet_pending(a)) { in esas2r_do_deferred_processes()
331 esas2r_schedule_tasklet(a); in esas2r_do_deferred_processes()
340 if (startreqs && !list_empty(&a->defer_list)) { in esas2r_do_deferred_processes()
344 spin_lock_irqsave(&a->queue_lock, flags); in esas2r_do_deferred_processes()
346 list_for_each_safe(element, next, &a->defer_list) { in esas2r_do_deferred_processes()
350 if (rq->req_stat != RS_PENDING) { in esas2r_do_deferred_processes()
352 list_add_tail(&rq->comp_list, &comp_list); in esas2r_do_deferred_processes()
360 else if (rq->req_type == RT_DISC_REQ) { in esas2r_do_deferred_processes()
362 esas2r_disc_local_start_request(a, rq); in esas2r_do_deferred_processes()
365 esas2r_local_start_request(a, rq); in esas2r_do_deferred_processes()
371 if (test_bit(AF_FLASHING, &a->flags)) in esas2r_do_deferred_processes()
376 spin_unlock_irqrestore(&a->queue_lock, flags); in esas2r_do_deferred_processes()
377 esas2r_comp_list_drain(a, &comp_list); in esas2r_do_deferred_processes()
380 atomic_dec(&a->disable_cnt); in esas2r_do_deferred_processes()
388 void esas2r_process_adapter_reset(struct esas2r_adapter *a) in esas2r_process_adapter_reset() argument
390 struct esas2r_request *rq = &a->general_req; in esas2r_process_adapter_reset()
399 spin_lock_irqsave(&a->queue_lock, flags); in esas2r_process_adapter_reset()
403 if (rq->interrupt_cx) { in esas2r_process_adapter_reset()
404 dc = (struct esas2r_disc_context *)rq->interrupt_cx; in esas2r_process_adapter_reset()
406 dc->disc_evt = 0; in esas2r_process_adapter_reset()
408 clear_bit(AF_DISC_IN_PROG, &a->flags); in esas2r_process_adapter_reset()
418 rq->interrupt_cx = NULL; in esas2r_process_adapter_reset()
419 rq->interrupt_cb = NULL; in esas2r_process_adapter_reset()
421 rq->comp_cb = esas2r_dummy_complete; in esas2r_process_adapter_reset()
425 *a->outbound_copy = in esas2r_process_adapter_reset()
426 a->last_write = in esas2r_process_adapter_reset()
427 a->last_read = a->list_size - 1; in esas2r_process_adapter_reset()
429 set_bit(AF_COMM_LIST_TOGGLE, &a->flags); in esas2r_process_adapter_reset()
432 list_for_each(element, &a->defer_list) { in esas2r_process_adapter_reset()
435 if (rq->req_stat == RS_STARTED) in esas2r_process_adapter_reset()
436 if (esas2r_ioreq_aborted(a, rq, RS_ABORTED)) in esas2r_process_adapter_reset()
437 list_add_tail(&rq->comp_list, &comp_list); in esas2r_process_adapter_reset()
440 spin_unlock_irqrestore(&a->queue_lock, flags); in esas2r_process_adapter_reset()
441 esas2r_comp_list_drain(a, &comp_list); in esas2r_process_adapter_reset()
442 esas2r_process_bus_reset(a); in esas2r_process_adapter_reset()
446 static void esas2r_process_bus_reset(struct esas2r_adapter *a) in esas2r_process_bus_reset() argument
458 spin_lock_irqsave(&a->queue_lock, flags); in esas2r_process_bus_reset()
461 list_for_each(element, &a->defer_list) { in esas2r_process_bus_reset()
463 if (esas2r_ioreq_aborted(a, rq, RS_ABORTED)) in esas2r_process_bus_reset()
464 list_add_tail(&rq->comp_list, &comp_list); in esas2r_process_bus_reset()
467 spin_unlock_irqrestore(&a->queue_lock, flags); in esas2r_process_bus_reset()
469 esas2r_comp_list_drain(a, &comp_list); in esas2r_process_bus_reset()
471 if (atomic_read(&a->disable_cnt) == 0) in esas2r_process_bus_reset()
472 esas2r_do_deferred_processes(a); in esas2r_process_bus_reset()
474 clear_bit(AF_OS_RESET, &a->flags); in esas2r_process_bus_reset()
479 static void esas2r_chip_rst_needed_during_tasklet(struct esas2r_adapter *a) in esas2r_chip_rst_needed_during_tasklet() argument
482 clear_bit(AF_CHPRST_NEEDED, &a->flags); in esas2r_chip_rst_needed_during_tasklet()
483 clear_bit(AF_BUSRST_NEEDED, &a->flags); in esas2r_chip_rst_needed_during_tasklet()
484 clear_bit(AF_BUSRST_DETECTED, &a->flags); in esas2r_chip_rst_needed_during_tasklet()
485 clear_bit(AF_BUSRST_PENDING, &a->flags); in esas2r_chip_rst_needed_during_tasklet()
492 * Each time we do a reset, we add 20 seconds worth to in esas2r_chip_rst_needed_during_tasklet()
493 * the count. Each time a timer tick occurs, as long in esas2r_chip_rst_needed_during_tasklet()
494 * as a chip reset is not pending, we decrement the in esas2r_chip_rst_needed_during_tasklet()
499 if (!esas2r_is_adapter_present(a) || (a->chip_uptime >= in esas2r_chip_rst_needed_during_tasklet()
511 set_bit(AF_DEGRADED_MODE, &a->flags); in esas2r_chip_rst_needed_during_tasklet()
512 set_bit(AF_DISABLED, &a->flags); in esas2r_chip_rst_needed_during_tasklet()
513 clear_bit(AF_CHPRST_PENDING, &a->flags); in esas2r_chip_rst_needed_during_tasklet()
514 clear_bit(AF_DISC_PENDING, &a->flags); in esas2r_chip_rst_needed_during_tasklet()
516 esas2r_disable_chip_interrupts(a); in esas2r_chip_rst_needed_during_tasklet()
517 a->int_mask = 0; in esas2r_chip_rst_needed_during_tasklet()
518 esas2r_process_adapter_reset(a); in esas2r_chip_rst_needed_during_tasklet()
523 bool alrdyrst = test_and_set_bit(AF_CHPRST_STARTED, &a->flags); in esas2r_chip_rst_needed_during_tasklet()
530 esas2r_disable_chip_interrupts(a); in esas2r_chip_rst_needed_during_tasklet()
532 if ((test_bit(AF_POWER_MGT, &a->flags)) && in esas2r_chip_rst_needed_during_tasklet()
533 !test_bit(AF_FIRST_INIT, &a->flags) && !alrdyrst) { in esas2r_chip_rst_needed_during_tasklet()
540 esas2r_reset_chip(a); in esas2r_chip_rst_needed_during_tasklet()
544 a->chip_uptime += ESAS2R_CHP_UPTIME_CNT; in esas2r_chip_rst_needed_during_tasklet()
545 a->chip_init_time = jiffies_to_msecs(jiffies); in esas2r_chip_rst_needed_during_tasklet()
546 if (!test_bit(AF_POWER_MGT, &a->flags)) { in esas2r_chip_rst_needed_during_tasklet()
547 esas2r_process_adapter_reset(a); in esas2r_chip_rst_needed_during_tasklet()
551 a->prev_dev_cnt = in esas2r_chip_rst_needed_during_tasklet()
552 esas2r_targ_db_get_tgt_cnt(a); in esas2r_chip_rst_needed_during_tasklet()
553 esas2r_targ_db_remove_all(a, false); in esas2r_chip_rst_needed_during_tasklet()
557 a->int_mask = 0; in esas2r_chip_rst_needed_during_tasklet()
561 static void esas2r_handle_chip_rst_during_tasklet(struct esas2r_adapter *a) in esas2r_handle_chip_rst_during_tasklet() argument
563 while (test_bit(AF_CHPRST_DETECTED, &a->flags)) { in esas2r_handle_chip_rst_during_tasklet()
569 if (!test_bit(AF_DEGRADED_MODE, &a->flags) && in esas2r_handle_chip_rst_during_tasklet()
570 !test_bit(AF_POWER_MGT, &a->flags)) in esas2r_handle_chip_rst_during_tasklet()
571 esas2r_disable_chip_interrupts(a); in esas2r_handle_chip_rst_during_tasklet()
574 esas2r_check_adapter(a); in esas2r_handle_chip_rst_during_tasklet()
575 esas2r_init_adapter_hw(a, 0); in esas2r_handle_chip_rst_during_tasklet()
577 if (test_bit(AF_CHPRST_NEEDED, &a->flags)) in esas2r_handle_chip_rst_during_tasklet()
580 if (test_bit(AF_POWER_MGT, &a->flags)) { in esas2r_handle_chip_rst_during_tasklet()
582 if (test_bit(AF_FIRST_INIT, &a->flags)) { in esas2r_handle_chip_rst_during_tasklet()
585 "The firmware was reset during a normal power-up sequence"); in esas2r_handle_chip_rst_during_tasklet()
588 clear_bit(AF_POWER_MGT, &a->flags); in esas2r_handle_chip_rst_during_tasklet()
589 esas2r_send_reset_ae(a, true); in esas2r_handle_chip_rst_during_tasklet()
593 if (test_bit(AF_FIRST_INIT, &a->flags)) { in esas2r_handle_chip_rst_during_tasklet()
597 esas2r_send_reset_ae(a, false); in esas2r_handle_chip_rst_during_tasklet()
601 "Recovering from a chip reset while the chip was online"); in esas2r_handle_chip_rst_during_tasklet()
604 clear_bit(AF_CHPRST_STARTED, &a->flags); in esas2r_handle_chip_rst_during_tasklet()
605 esas2r_enable_chip_interrupts(a); in esas2r_handle_chip_rst_during_tasklet()
611 clear_bit(AF_CHPRST_DETECTED, &a->flags); in esas2r_handle_chip_rst_during_tasklet()
617 void esas2r_do_tasklet_tasks(struct esas2r_adapter *a) in esas2r_do_tasklet_tasks() argument
620 if (test_bit(AF_CHPRST_NEEDED, &a->flags) || in esas2r_do_tasklet_tasks()
621 test_bit(AF_CHPRST_DETECTED, &a->flags)) { in esas2r_do_tasklet_tasks()
622 if (test_bit(AF_CHPRST_NEEDED, &a->flags)) in esas2r_do_tasklet_tasks()
623 esas2r_chip_rst_needed_during_tasklet(a); in esas2r_do_tasklet_tasks()
625 esas2r_handle_chip_rst_during_tasklet(a); in esas2r_do_tasklet_tasks()
628 if (test_bit(AF_BUSRST_NEEDED, &a->flags)) { in esas2r_do_tasklet_tasks()
631 clear_bit(AF_BUSRST_NEEDED, &a->flags); in esas2r_do_tasklet_tasks()
633 if (test_bit(AF_FLASHING, &a->flags)) in esas2r_do_tasklet_tasks()
634 set_bit(AF_BUSRST_DETECTED, &a->flags); in esas2r_do_tasklet_tasks()
636 esas2r_write_register_dword(a, MU_DOORBELL_IN, in esas2r_do_tasklet_tasks()
640 if (test_bit(AF_BUSRST_DETECTED, &a->flags)) { in esas2r_do_tasklet_tasks()
641 esas2r_process_bus_reset(a); in esas2r_do_tasklet_tasks()
644 &(a->host->shost_gendev), in esas2r_do_tasklet_tasks()
647 scsi_report_bus_reset(a->host, 0); in esas2r_do_tasklet_tasks()
649 clear_bit(AF_BUSRST_DETECTED, &a->flags); in esas2r_do_tasklet_tasks()
650 clear_bit(AF_BUSRST_PENDING, &a->flags); in esas2r_do_tasklet_tasks()
655 if (test_bit(AF_PORT_CHANGE, &a->flags)) { in esas2r_do_tasklet_tasks()
656 clear_bit(AF_PORT_CHANGE, &a->flags); in esas2r_do_tasklet_tasks()
658 esas2r_targ_db_report_changes(a); in esas2r_do_tasklet_tasks()
661 if (atomic_read(&a->disable_cnt) == 0) in esas2r_do_tasklet_tasks()
662 esas2r_do_deferred_processes(a); in esas2r_do_tasklet_tasks()
665 static void esas2r_doorbell_interrupt(struct esas2r_adapter *a, u32 doorbell) in esas2r_doorbell_interrupt() argument
673 esas2r_write_register_dword(a, MU_DOORBELL_OUT, doorbell); in esas2r_doorbell_interrupt()
676 set_bit(AF_BUSRST_DETECTED, &a->flags); in esas2r_doorbell_interrupt()
679 clear_bit(AF_HEARTBEAT, &a->flags); in esas2r_doorbell_interrupt()
687 set_bit(AF2_COREDUMP_AVAIL, &a->flags2); in esas2r_doorbell_interrupt()
688 esas2r_local_reset_adapter(a); in esas2r_doorbell_interrupt()
696 void esas2r_force_interrupt(struct esas2r_adapter *a) in esas2r_force_interrupt() argument
698 esas2r_write_register_dword(a, MU_DOORBELL_IN, DRBL_FORCE_INT | in esas2r_force_interrupt()
703 static void esas2r_lun_event(struct esas2r_adapter *a, union atto_vda_ae *ae, in esas2r_lun_event() argument
706 struct esas2r_target *t = a->targetdb + target; in esas2r_lun_event()
710 if (cplen > sizeof(t->lu_event)) in esas2r_lun_event()
711 cplen = sizeof(t->lu_event); in esas2r_lun_event()
713 esas2r_trace("ae->lu.dwevent: %x", ae->lu.dwevent); in esas2r_lun_event()
714 esas2r_trace("ae->lu.bystate: %x", ae->lu.bystate); in esas2r_lun_event()
716 spin_lock_irqsave(&a->mem_lock, flags); in esas2r_lun_event()
718 t->new_target_state = TS_INVALID; in esas2r_lun_event()
720 if (ae->lu.dwevent & VDAAE_LU_LOST) { in esas2r_lun_event()
721 t->new_target_state = TS_NOT_PRESENT; in esas2r_lun_event()
723 switch (ae->lu.bystate) { in esas2r_lun_event()
728 t->new_target_state = TS_NOT_PRESENT; in esas2r_lun_event()
733 t->new_target_state = TS_PRESENT; in esas2r_lun_event()
738 if (t->new_target_state != TS_INVALID) { in esas2r_lun_event()
739 memcpy(&t->lu_event, &ae->lu, cplen); in esas2r_lun_event()
741 esas2r_disc_queue_event(a, DCDE_DEV_CHANGE); in esas2r_lun_event()
744 spin_unlock_irqrestore(&a->mem_lock, flags); in esas2r_lun_event()
749 void esas2r_ae_complete(struct esas2r_adapter *a, struct esas2r_request *rq) in esas2r_ae_complete() argument
752 (union atto_vda_ae *)rq->vda_rsp_data->ae_data.event_data; in esas2r_ae_complete()
753 u32 length = le32_to_cpu(rq->func_rsp.ae_rsp.length); in esas2r_ae_complete()
755 (union atto_vda_ae *)(rq->vda_rsp_data->ae_data.event_data in esas2r_ae_complete()
768 esas2r_hdebug("aereq->length (0x%x) too long", length); in esas2r_ae_complete()
778 esas2r_trace("ae->hdr: %p", &(ae->hdr)); in esas2r_ae_complete()
780 length = ae->hdr.bylength; in esas2r_ae_complete()
782 if (length > (u32)((u8 *)last - (u8 *)ae) in esas2r_ae_complete()
789 esas2r_hdebug("ae->hdr.length (0x%x) invalid", length); in esas2r_ae_complete()
797 esas2r_queue_fw_event(a, fw_event_vda_ae, ae, in esas2r_ae_complete()
800 switch (ae->hdr.bytype) { in esas2r_ae_complete()
803 if (ae->raid.dwflags & (VDAAE_GROUP_STATE in esas2r_ae_complete()
808 "RAID event received - name:%s rebuild_state:%d group_state:%d", in esas2r_ae_complete()
809 ae->raid.acname, in esas2r_ae_complete()
810 ae->raid.byrebuild_state, in esas2r_ae_complete()
811 ae->raid.bygroup_state); in esas2r_ae_complete()
819 ae->lu.dwevent, in esas2r_ae_complete()
820 ae->lu.id.tgtlun.wtarget_id, in esas2r_ae_complete()
821 ae->lu.id.tgtlun.bylun, in esas2r_ae_complete()
822 ae->lu.bystate); in esas2r_ae_complete()
824 target = ae->lu.id.tgtlun.wtarget_id; in esas2r_ae_complete()
827 esas2r_lun_event(a, ae, target, length); in esas2r_ae_complete()
848 esas2r_start_ae_request(a, rq); in esas2r_ae_complete()
852 /* Send an asynchronous event for a chip reset or power management. */
853 void esas2r_send_reset_ae(struct esas2r_adapter *a, bool pwr_mgt) in esas2r_send_reset_ae() argument
872 esas2r_queue_fw_event(a, fw_event_vda_ae, &ae, in esas2r_send_reset_ae()
876 void esas2r_dummy_complete(struct esas2r_adapter *a, struct esas2r_request *rq) in esas2r_dummy_complete() argument
879 static void esas2r_check_req_rsp_sense(struct esas2r_adapter *a, in esas2r_check_req_rsp_sense() argument
884 snslen = snslen2 = rq->func_rsp.scsi_rsp.sense_len; in esas2r_check_req_rsp_sense()
886 if (snslen > rq->sense_len) in esas2r_check_req_rsp_sense()
887 snslen = rq->sense_len; in esas2r_check_req_rsp_sense()
890 if (rq->sense_buf) in esas2r_check_req_rsp_sense()
891 memcpy(rq->sense_buf, rq->data_buf, snslen); in esas2r_check_req_rsp_sense()
893 rq->sense_buf = (u8 *)rq->data_buf; in esas2r_check_req_rsp_sense()
897 u8 *s = (u8 *)rq->data_buf; in esas2r_check_req_rsp_sense()
903 esas2r_trace("rq->target_id: %d", in esas2r_check_req_rsp_sense()
904 rq->target_id); in esas2r_check_req_rsp_sense()
905 esas2r_target_state_changed(a, rq->target_id, in esas2r_check_req_rsp_sense()
915 rq->sense_len = snslen; in esas2r_check_req_rsp_sense()
919 void esas2r_complete_request(struct esas2r_adapter *a, in esas2r_complete_request() argument
922 if (rq->vrq->scsi.function == VDA_FUNC_FLASH in esas2r_complete_request()
923 && rq->vrq->flash.sub_func == VDA_FLASH_COMMIT) in esas2r_complete_request()
924 clear_bit(AF_FLASHING, &a->flags); in esas2r_complete_request()
926 /* See if we setup a callback to do special processing */ in esas2r_complete_request()
928 if (rq->interrupt_cb) { in esas2r_complete_request()
929 (*rq->interrupt_cb)(a, rq); in esas2r_complete_request()
931 if (rq->req_stat == RS_PENDING) { in esas2r_complete_request()
932 esas2r_start_request(a, rq); in esas2r_complete_request()
937 if (likely(rq->vrq->scsi.function == VDA_FUNC_SCSI) in esas2r_complete_request()
938 && unlikely(rq->req_stat != RS_SUCCESS)) { in esas2r_complete_request()
939 esas2r_check_req_rsp_sense(a, rq); in esas2r_complete_request()
940 esas2r_log_request_failure(a, rq); in esas2r_complete_request()
943 (*rq->comp_cb)(a, rq); in esas2r_complete_request()