Lines Matching +full:dc +full:- +full:to +full:- +full:dc

5  *  Copyright (c) 2001-2013 ATTO Technology, Inc.
8 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
22 * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
26 * exercise of rights under this Agreement, including but not limited to
27 * the risks and costs of program errors, damage to or loss of data,
40 * along with this program; if not, write to the Free Software
41 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
43 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
85 struct esas2r_sas_nvram *nvr = a->nvram; in esas2r_disc_initialize()
89 clear_bit(AF_DISC_IN_PROG, &a->flags); in esas2r_disc_initialize()
90 clear_bit(AF2_DEV_SCAN, &a->flags2); in esas2r_disc_initialize()
91 clear_bit(AF2_DEV_CNT_OK, &a->flags2); in esas2r_disc_initialize()
93 a->disc_start_time = jiffies_to_msecs(jiffies); in esas2r_disc_initialize()
94 a->disc_wait_time = nvr->dev_wait_time * 1000; in esas2r_disc_initialize()
95 a->disc_wait_cnt = nvr->dev_wait_count; in esas2r_disc_initialize()
97 if (a->disc_wait_cnt > ESAS2R_MAX_TARGETS) in esas2r_disc_initialize()
98 a->disc_wait_cnt = ESAS2R_MAX_TARGETS; in esas2r_disc_initialize()
108 a->general_req.interrupt_cx = NULL; in esas2r_disc_initialize()
110 if (test_bit(AF_CHPRST_DETECTED, &a->flags) || in esas2r_disc_initialize()
111 test_bit(AF_POWER_MGT, &a->flags)) { in esas2r_disc_initialize()
112 if (a->prev_dev_cnt == 0) { in esas2r_disc_initialize()
113 /* Don't bother waiting if there is nothing to wait in esas2r_disc_initialize()
116 a->disc_wait_time = 0; in esas2r_disc_initialize()
119 * Set the device wait count to what was previously in esas2r_disc_initialize()
121 * a time because we know the exact count to wait for. in esas2r_disc_initialize()
122 * There is no need to honor the user's wishes to in esas2r_disc_initialize()
125 a->disc_wait_cnt = a->prev_dev_cnt; in esas2r_disc_initialize()
128 * bump the minimum wait time to 15 seconds since the in esas2r_disc_initialize()
132 if (a->disc_wait_time < 15000) in esas2r_disc_initialize()
133 a->disc_wait_time = 15000; in esas2r_disc_initialize()
137 esas2r_trace("disc wait count: %d", a->disc_wait_cnt); in esas2r_disc_initialize()
138 esas2r_trace("disc wait time: %d", a->disc_wait_time); in esas2r_disc_initialize()
140 if (a->disc_wait_time == 0) in esas2r_disc_initialize()
150 spin_lock_irqsave(&a->mem_lock, flags); in esas2r_disc_start_waiting()
152 if (a->disc_ctx.disc_evt) in esas2r_disc_start_waiting()
155 spin_unlock_irqrestore(&a->mem_lock, flags); in esas2r_disc_start_waiting()
160 struct esas2r_request *rq = &a->general_req; in esas2r_disc_check_for_work()
168 * see if we have one to start. we couldn't start it in the ISR since in esas2r_disc_check_for_work()
174 if (rq->interrupt_cx == NULL) in esas2r_disc_check_for_work()
177 if (rq->req_stat == RS_STARTED in esas2r_disc_check_for_work()
178 && rq->timeout <= RQ_MAX_TIMEOUT) { in esas2r_disc_check_for_work()
179 /* wait for the current discovery request to complete. */ in esas2r_disc_check_for_work()
182 if (rq->req_stat == RS_TIMEOUT) { in esas2r_disc_check_for_work()
189 if (rq->req_stat == RS_PENDING in esas2r_disc_check_for_work()
190 || rq->req_stat == RS_STARTED) in esas2r_disc_check_for_work()
202 /* check to see if we should be waiting for devices */ in esas2r_disc_check_complete()
203 if (a->disc_wait_time) { in esas2r_disc_check_complete()
205 u32 time = currtime - a->disc_start_time; in esas2r_disc_check_complete()
211 if (time < a->disc_wait_time in esas2r_disc_check_complete()
212 && (esas2r_targ_db_get_tgt_cnt(a) < a->disc_wait_cnt in esas2r_disc_check_complete()
213 || a->disc_wait_cnt == 0)) { in esas2r_disc_check_complete()
216 && !test_and_set_bit(AF2_DEV_SCAN, &a->flags2)) { in esas2r_disc_check_complete()
217 spin_lock_irqsave(&a->mem_lock, flags); in esas2r_disc_check_complete()
219 spin_unlock_irqrestore(&a->mem_lock, flags); in esas2r_disc_check_complete()
227 * We are done waiting...we think. Adjust the wait time to in esas2r_disc_check_complete()
230 if (!test_and_set_bit(AF2_DEV_CNT_OK, &a->flags2)) in esas2r_disc_check_complete()
231 a->disc_wait_time = time + 3000; in esas2r_disc_check_complete()
234 if (!test_and_set_bit(AF2_DEV_SCAN, &a->flags2)) { in esas2r_disc_check_complete()
235 spin_lock_irqsave(&a->mem_lock, flags); in esas2r_disc_check_complete()
237 spin_unlock_irqrestore(&a->mem_lock, flags); in esas2r_disc_check_complete()
243 * Now, if there is still time left to consume events, continue in esas2r_disc_check_complete()
246 if (time < a->disc_wait_time) { in esas2r_disc_check_complete()
251 if (!test_and_set_bit(AF2_DEV_SCAN, &a->flags2)) { in esas2r_disc_check_complete()
252 spin_lock_irqsave(&a->mem_lock, flags); in esas2r_disc_check_complete()
254 spin_unlock_irqrestore(&a->mem_lock, flags); in esas2r_disc_check_complete()
258 /* We want to stop waiting for devices. */ in esas2r_disc_check_complete()
259 a->disc_wait_time = 0; in esas2r_disc_check_complete()
261 if (test_bit(AF_DISC_POLLED, &a->flags) && in esas2r_disc_check_complete()
262 test_bit(AF_DISC_IN_PROG, &a->flags)) { in esas2r_disc_check_complete()
266 * polled discovery and transition to interrupt driven in esas2r_disc_check_complete()
276 clear_bit(AF_DISC_PENDING, &a->flags); in esas2r_disc_check_complete()
280 * don't want to report any removals (due to the first arrival) in esas2r_disc_check_complete()
283 set_bit(AF_PORT_CHANGE, &a->flags); in esas2r_disc_check_complete()
291 struct esas2r_disc_context *dc = &a->disc_ctx; in esas2r_disc_queue_event() local
298 dc->disc_evt |= disc_evt; in esas2r_disc_queue_event()
304 if (!test_bit(AF_CHPRST_PENDING, &a->flags) && in esas2r_disc_queue_event()
305 !test_bit(AF_DISC_POLLED, &a->flags)) in esas2r_disc_queue_event()
313 struct esas2r_request *rq = &a->general_req; in esas2r_disc_start_port()
314 struct esas2r_disc_context *dc = &a->disc_ctx; in esas2r_disc_start_port() local
319 if (test_bit(AF_DISC_IN_PROG, &a->flags)) { in esas2r_disc_start_port()
326 if (dc->disc_evt) { in esas2r_disc_start_port()
327 if (test_bit(AF_DISC_POLLED, &a->flags) in esas2r_disc_start_port()
328 && a->disc_wait_time == 0) { in esas2r_disc_start_port()
331 * to wait for devices. Stop polled discovery and in esas2r_disc_start_port()
332 * transition to interrupt driven discovery. in esas2r_disc_start_port()
344 set_bit(AF_PORT_CHANGE, &a->flags); in esas2r_disc_start_port()
352 esas2r_trace("disc_evt: %d", dc->disc_evt); in esas2r_disc_start_port()
353 set_bit(AF_DISC_IN_PROG, &a->flags); in esas2r_disc_start_port()
354 dc->flags = 0; in esas2r_disc_start_port()
356 if (test_bit(AF_DISC_POLLED, &a->flags)) in esas2r_disc_start_port()
357 dc->flags |= DCF_POLLED; in esas2r_disc_start_port()
359 rq->interrupt_cx = dc; in esas2r_disc_start_port()
360 rq->req_stat = RS_SUCCESS; in esas2r_disc_start_port()
363 if (dc->disc_evt & DCDE_DEV_SCAN) { in esas2r_disc_start_port()
364 dc->disc_evt &= ~DCDE_DEV_SCAN; in esas2r_disc_start_port()
366 dc->flags |= DCF_DEV_SCAN; in esas2r_disc_start_port()
367 dc->state = DCS_BLOCK_DEV_SCAN; in esas2r_disc_start_port()
368 } else if (dc->disc_evt & DCDE_DEV_CHANGE) { in esas2r_disc_start_port()
369 dc->disc_evt &= ~DCDE_DEV_CHANGE; in esas2r_disc_start_port()
371 dc->flags |= DCF_DEV_CHANGE; in esas2r_disc_start_port()
372 dc->state = DCS_DEV_RMV; in esas2r_disc_start_port()
376 if (!test_bit(AF_DISC_POLLED, &a->flags)) in esas2r_disc_start_port()
389 struct esas2r_disc_context *dc = in esas2r_disc_continue() local
390 (struct esas2r_disc_context *)rq->interrupt_cx; in esas2r_disc_continue()
394 while (dc->flags & (DCF_DEV_CHANGE | DCF_DEV_SCAN)) { in esas2r_disc_continue()
397 switch (dc->state) { in esas2r_disc_continue()
433 dc->flags &= ~(DCF_DEV_CHANGE | DCF_DEV_SCAN); in esas2r_disc_continue()
439 dc->state = DCS_DISC_DONE; in esas2r_disc_continue()
448 rq->interrupt_cx = NULL; in esas2r_disc_continue()
450 if (!test_bit(AF_DISC_PENDING, &a->flags)) in esas2r_disc_continue()
453 clear_bit(AF_DISC_IN_PROG, &a->flags); in esas2r_disc_continue()
464 /* Set the timeout to a minimum value. */ in esas2r_disc_start_request()
465 if (rq->timeout < ESAS2R_DEFAULT_TMO) in esas2r_disc_start_request()
466 rq->timeout = ESAS2R_DEFAULT_TMO; in esas2r_disc_start_request()
469 * Override the request type to distinguish discovery requests. If we in esas2r_disc_start_request()
471 * will be called to restart it. in esas2r_disc_start_request()
473 rq->req_type = RT_DISC_REQ; in esas2r_disc_start_request()
475 spin_lock_irqsave(&a->queue_lock, flags); in esas2r_disc_start_request()
477 if (!test_bit(AF_CHPRST_PENDING, &a->flags) && in esas2r_disc_start_request()
478 !test_bit(AF_FLASHING, &a->flags)) in esas2r_disc_start_request()
481 list_add_tail(&rq->req_list, &a->defer_list); in esas2r_disc_start_request()
483 spin_unlock_irqrestore(&a->queue_lock, flags); in esas2r_disc_start_request()
493 list_add_tail(&rq->req_list, &a->active_list); in esas2r_disc_local_start_request()
505 struct esas2r_disc_context *dc = in esas2r_disc_abort() local
506 (struct esas2r_disc_context *)rq->interrupt_cx; in esas2r_disc_abort()
512 dc->state = DCS_DISC_DONE; in esas2r_disc_abort()
520 struct esas2r_disc_context *dc = in esas2r_disc_block_dev_scan() local
521 (struct esas2r_disc_context *)rq->interrupt_cx; in esas2r_disc_block_dev_scan()
536 rq->comp_cb = esas2r_disc_block_dev_scan_cb; in esas2r_disc_block_dev_scan()
538 rq->timeout = 30000; in esas2r_disc_block_dev_scan()
539 rq->interrupt_cx = dc; in esas2r_disc_block_dev_scan()
551 struct esas2r_disc_context *dc = in esas2r_disc_block_dev_scan_cb() local
552 (struct esas2r_disc_context *)rq->interrupt_cx; in esas2r_disc_block_dev_scan_cb()
557 spin_lock_irqsave(&a->mem_lock, flags); in esas2r_disc_block_dev_scan_cb()
559 if (rq->req_stat == RS_SUCCESS) in esas2r_disc_block_dev_scan_cb()
560 dc->scan_gen = rq->func_rsp.mgt_rsp.scan_generation; in esas2r_disc_block_dev_scan_cb()
562 dc->state = DCS_RAID_GRP_INFO; in esas2r_disc_block_dev_scan_cb()
563 dc->raid_grp_ix = 0; in esas2r_disc_block_dev_scan_cb()
569 if (!(dc->flags & DCF_POLLED)) in esas2r_disc_block_dev_scan_cb()
572 spin_unlock_irqrestore(&a->mem_lock, flags); in esas2r_disc_block_dev_scan_cb()
580 struct esas2r_disc_context *dc = in esas2r_disc_raid_grp_info() local
581 (struct esas2r_disc_context *)rq->interrupt_cx; in esas2r_disc_raid_grp_info()
587 esas2r_trace("raid_group_idx: %d", dc->raid_grp_ix); in esas2r_disc_raid_grp_info()
589 if (dc->raid_grp_ix >= VDA_MAX_RAID_GROUPS) { in esas2r_disc_raid_grp_info()
590 dc->state = DCS_DISC_DONE; in esas2r_disc_raid_grp_info()
599 grpinfo = &rq->vda_rsp_data->mgt_data.data.grp_info; in esas2r_disc_raid_grp_info()
606 dc->scan_gen, in esas2r_disc_raid_grp_info()
611 grpinfo->grp_index = dc->raid_grp_ix; in esas2r_disc_raid_grp_info()
613 rq->comp_cb = esas2r_disc_raid_grp_info_cb; in esas2r_disc_raid_grp_info()
615 rq->interrupt_cx = dc; in esas2r_disc_raid_grp_info()
627 struct esas2r_disc_context *dc = in esas2r_disc_raid_grp_info_cb() local
628 (struct esas2r_disc_context *)rq->interrupt_cx; in esas2r_disc_raid_grp_info_cb()
634 spin_lock_irqsave(&a->mem_lock, flags); in esas2r_disc_raid_grp_info_cb()
636 if (rq->req_stat == RS_SCAN_GEN) { in esas2r_disc_raid_grp_info_cb()
637 dc->scan_gen = rq->func_rsp.mgt_rsp.scan_generation; in esas2r_disc_raid_grp_info_cb()
638 dc->raid_grp_ix = 0; in esas2r_disc_raid_grp_info_cb()
642 if (rq->req_stat == RS_SUCCESS) { in esas2r_disc_raid_grp_info_cb()
643 grpinfo = &rq->vda_rsp_data->mgt_data.data.grp_info; in esas2r_disc_raid_grp_info_cb()
645 if (grpinfo->status != VDA_GRP_STAT_ONLINE in esas2r_disc_raid_grp_info_cb()
646 && grpinfo->status != VDA_GRP_STAT_DEGRADED) { in esas2r_disc_raid_grp_info_cb()
647 /* go to the next group. */ in esas2r_disc_raid_grp_info_cb()
649 dc->raid_grp_ix++; in esas2r_disc_raid_grp_info_cb()
651 memcpy(&dc->raid_grp_name[0], in esas2r_disc_raid_grp_info_cb()
652 &grpinfo->grp_name[0], in esas2r_disc_raid_grp_info_cb()
653 sizeof(grpinfo->grp_name)); in esas2r_disc_raid_grp_info_cb()
655 dc->interleave = le32_to_cpu(grpinfo->interleave); in esas2r_disc_raid_grp_info_cb()
656 dc->block_size = le32_to_cpu(grpinfo->block_size); in esas2r_disc_raid_grp_info_cb()
658 dc->state = DCS_PART_INFO; in esas2r_disc_raid_grp_info_cb()
659 dc->part_num = 0; in esas2r_disc_raid_grp_info_cb()
662 if (!(rq->req_stat == RS_GRP_INVALID)) { in esas2r_disc_raid_grp_info_cb()
664 "A request for RAID group info failed - " in esas2r_disc_raid_grp_info_cb()
666 rq->req_stat); in esas2r_disc_raid_grp_info_cb()
669 dc->dev_ix = 0; in esas2r_disc_raid_grp_info_cb()
670 dc->state = DCS_PT_DEV_INFO; in esas2r_disc_raid_grp_info_cb()
679 if (!(dc->flags & DCF_POLLED)) in esas2r_disc_raid_grp_info_cb()
682 spin_unlock_irqrestore(&a->mem_lock, flags); in esas2r_disc_raid_grp_info_cb()
690 struct esas2r_disc_context *dc = in esas2r_disc_part_info() local
691 (struct esas2r_disc_context *)rq->interrupt_cx; in esas2r_disc_part_info()
697 esas2r_trace("part_num: %d", dc->part_num); in esas2r_disc_part_info()
699 if (dc->part_num >= VDA_MAX_PARTITIONS) { in esas2r_disc_part_info()
700 dc->state = DCS_RAID_GRP_INFO; in esas2r_disc_part_info()
701 dc->raid_grp_ix++; in esas2r_disc_part_info()
710 partinfo = &rq->vda_rsp_data->mgt_data.data.part_info; in esas2r_disc_part_info()
717 dc->scan_gen, in esas2r_disc_part_info()
722 partinfo->part_no = dc->part_num; in esas2r_disc_part_info()
724 memcpy(&partinfo->grp_name[0], in esas2r_disc_part_info()
725 &dc->raid_grp_name[0], in esas2r_disc_part_info()
726 sizeof(partinfo->grp_name)); in esas2r_disc_part_info()
728 rq->comp_cb = esas2r_disc_part_info_cb; in esas2r_disc_part_info()
730 rq->interrupt_cx = dc; in esas2r_disc_part_info()
742 struct esas2r_disc_context *dc = in esas2r_disc_part_info_cb() local
743 (struct esas2r_disc_context *)rq->interrupt_cx; in esas2r_disc_part_info_cb()
749 spin_lock_irqsave(&a->mem_lock, flags); in esas2r_disc_part_info_cb()
751 if (rq->req_stat == RS_SCAN_GEN) { in esas2r_disc_part_info_cb()
752 dc->scan_gen = rq->func_rsp.mgt_rsp.scan_generation; in esas2r_disc_part_info_cb()
753 dc->raid_grp_ix = 0; in esas2r_disc_part_info_cb()
754 dc->state = DCS_RAID_GRP_INFO; in esas2r_disc_part_info_cb()
755 } else if (rq->req_stat == RS_SUCCESS) { in esas2r_disc_part_info_cb()
756 partinfo = &rq->vda_rsp_data->mgt_data.data.part_info; in esas2r_disc_part_info_cb()
758 dc->part_num = partinfo->part_no; in esas2r_disc_part_info_cb()
760 dc->curr_virt_id = le16_to_cpu(partinfo->target_id); in esas2r_disc_part_info_cb()
762 esas2r_targ_db_add_raid(a, dc); in esas2r_disc_part_info_cb()
764 dc->part_num++; in esas2r_disc_part_info_cb()
766 if (!(rq->req_stat == RS_PART_LAST)) { in esas2r_disc_part_info_cb()
769 "failed - status:%d", rq->req_stat); in esas2r_disc_part_info_cb()
772 dc->state = DCS_RAID_GRP_INFO; in esas2r_disc_part_info_cb()
773 dc->raid_grp_ix++; in esas2r_disc_part_info_cb()
780 if (!(dc->flags & DCF_POLLED)) in esas2r_disc_part_info_cb()
783 spin_unlock_irqrestore(&a->mem_lock, flags); in esas2r_disc_part_info_cb()
791 struct esas2r_disc_context *dc = in esas2r_disc_passthru_dev_info() local
792 (struct esas2r_disc_context *)rq->interrupt_cx; in esas2r_disc_passthru_dev_info()
798 esas2r_trace("dev_ix: %d", dc->dev_ix); in esas2r_disc_passthru_dev_info()
802 devinfo = &rq->vda_rsp_data->mgt_data.data.dev_info; in esas2r_disc_passthru_dev_info()
809 dc->scan_gen, in esas2r_disc_passthru_dev_info()
810 dc->dev_ix, in esas2r_disc_passthru_dev_info()
814 rq->comp_cb = esas2r_disc_passthru_dev_info_cb; in esas2r_disc_passthru_dev_info()
816 rq->interrupt_cx = dc; in esas2r_disc_passthru_dev_info()
828 struct esas2r_disc_context *dc = in esas2r_disc_passthru_dev_info_cb() local
829 (struct esas2r_disc_context *)rq->interrupt_cx; in esas2r_disc_passthru_dev_info_cb()
835 spin_lock_irqsave(&a->mem_lock, flags); in esas2r_disc_passthru_dev_info_cb()
837 if (rq->req_stat == RS_SCAN_GEN) { in esas2r_disc_passthru_dev_info_cb()
838 dc->scan_gen = rq->func_rsp.mgt_rsp.scan_generation; in esas2r_disc_passthru_dev_info_cb()
839 dc->dev_ix = 0; in esas2r_disc_passthru_dev_info_cb()
840 dc->state = DCS_PT_DEV_INFO; in esas2r_disc_passthru_dev_info_cb()
841 } else if (rq->req_stat == RS_SUCCESS) { in esas2r_disc_passthru_dev_info_cb()
842 devinfo = &rq->vda_rsp_data->mgt_data.data.dev_info; in esas2r_disc_passthru_dev_info_cb()
844 dc->dev_ix = le16_to_cpu(rq->func_rsp.mgt_rsp.dev_index); in esas2r_disc_passthru_dev_info_cb()
846 dc->curr_virt_id = le16_to_cpu(devinfo->target_id); in esas2r_disc_passthru_dev_info_cb()
848 if (le16_to_cpu(devinfo->features) & VDADEVFEAT_PHYS_ID) { in esas2r_disc_passthru_dev_info_cb()
849 dc->curr_phys_id = in esas2r_disc_passthru_dev_info_cb()
850 le16_to_cpu(devinfo->phys_target_id); in esas2r_disc_passthru_dev_info_cb()
851 dc->dev_addr_type = ATTO_GDA_AT_PORT; in esas2r_disc_passthru_dev_info_cb()
852 dc->state = DCS_PT_DEV_ADDR; in esas2r_disc_passthru_dev_info_cb()
854 esas2r_trace("curr_virt_id: %d", dc->curr_virt_id); in esas2r_disc_passthru_dev_info_cb()
855 esas2r_trace("curr_phys_id: %d", dc->curr_phys_id); in esas2r_disc_passthru_dev_info_cb()
857 dc->dev_ix++; in esas2r_disc_passthru_dev_info_cb()
860 if (!(rq->req_stat == RS_DEV_INVALID)) { in esas2r_disc_passthru_dev_info_cb()
862 "A request for device information failed - " in esas2r_disc_passthru_dev_info_cb()
863 "status:%d", rq->req_stat); in esas2r_disc_passthru_dev_info_cb()
866 dc->state = DCS_DISC_DONE; in esas2r_disc_passthru_dev_info_cb()
873 if (!(dc->flags & DCF_POLLED)) in esas2r_disc_passthru_dev_info_cb()
876 spin_unlock_irqrestore(&a->mem_lock, flags); in esas2r_disc_passthru_dev_info_cb()
884 struct esas2r_disc_context *dc = in esas2r_disc_passthru_dev_addr() local
885 (struct esas2r_disc_context *)rq->interrupt_cx; in esas2r_disc_passthru_dev_addr()
901 esas2r_sgc_init(&sgc, a, rq, rq->vrq->ioctl.sge); in esas2r_disc_passthru_dev_addr()
913 rq->comp_cb = esas2r_disc_passthru_dev_addr_cb; in esas2r_disc_passthru_dev_addr()
915 rq->interrupt_cx = dc; in esas2r_disc_passthru_dev_addr()
919 hi = (struct atto_ioctl *)a->disc_buffer; in esas2r_disc_passthru_dev_addr()
921 memset(a->disc_buffer, 0, ESAS2R_DISC_BUF_LEN); in esas2r_disc_passthru_dev_addr()
923 hi->version = ATTO_VER_GET_DEV_ADDR0; in esas2r_disc_passthru_dev_addr()
924 hi->function = ATTO_FUNC_GET_DEV_ADDR; in esas2r_disc_passthru_dev_addr()
925 hi->flags = HBAF_TUNNEL; in esas2r_disc_passthru_dev_addr()
927 hi->data.get_dev_addr.target_id = le32_to_cpu(dc->curr_phys_id); in esas2r_disc_passthru_dev_addr()
928 hi->data.get_dev_addr.addr_type = dc->dev_addr_type; in esas2r_disc_passthru_dev_addr()
942 struct esas2r_disc_context *dc = in esas2r_disc_passthru_dev_addr_cb() local
943 (struct esas2r_disc_context *)rq->interrupt_cx; in esas2r_disc_passthru_dev_addr_cb()
951 spin_lock_irqsave(&a->mem_lock, flags); in esas2r_disc_passthru_dev_addr_cb()
953 hi = (struct atto_ioctl *)a->disc_buffer; in esas2r_disc_passthru_dev_addr_cb()
955 if (rq->req_stat == RS_SUCCESS in esas2r_disc_passthru_dev_addr_cb()
956 && hi->status == ATTO_STS_SUCCESS) { in esas2r_disc_passthru_dev_addr_cb()
957 addrlen = le16_to_cpu(hi->data.get_dev_addr.addr_len); in esas2r_disc_passthru_dev_addr_cb()
959 if (dc->dev_addr_type == ATTO_GDA_AT_PORT) { in esas2r_disc_passthru_dev_addr_cb()
961 memcpy(&dc->sas_addr, in esas2r_disc_passthru_dev_addr_cb()
962 &hi->data.get_dev_addr.address[0], in esas2r_disc_passthru_dev_addr_cb()
965 memset(&dc->sas_addr, 0, sizeof(dc->sas_addr)); in esas2r_disc_passthru_dev_addr_cb()
968 dc->dev_addr_type = ATTO_GDA_AT_UNIQUE; in esas2r_disc_passthru_dev_addr_cb()
975 dc, in esas2r_disc_passthru_dev_addr_cb()
976 &hi->data. in esas2r_disc_passthru_dev_addr_cb()
979 (u8)hi->data. in esas2r_disc_passthru_dev_addr_cb()
984 memcpy(&t->sas_addr, &dc->sas_addr, in esas2r_disc_passthru_dev_addr_cb()
985 sizeof(t->sas_addr)); in esas2r_disc_passthru_dev_addr_cb()
1000 "an error occurred retrieving the back end data - " in esas2r_disc_passthru_dev_addr_cb()
1001 "rq->req_stat:%d hi->status:%d", in esas2r_disc_passthru_dev_addr_cb()
1002 rq->req_stat, hi->status); in esas2r_disc_passthru_dev_addr_cb()
1005 /* proceed to the next device. */ in esas2r_disc_passthru_dev_addr_cb()
1007 if (dc->flags & DCF_DEV_SCAN) { in esas2r_disc_passthru_dev_addr_cb()
1008 dc->dev_ix++; in esas2r_disc_passthru_dev_addr_cb()
1009 dc->state = DCS_PT_DEV_INFO; in esas2r_disc_passthru_dev_addr_cb()
1010 } else if (dc->flags & DCF_DEV_CHANGE) { in esas2r_disc_passthru_dev_addr_cb()
1011 dc->curr_targ++; in esas2r_disc_passthru_dev_addr_cb()
1012 dc->state = DCS_DEV_ADD; in esas2r_disc_passthru_dev_addr_cb()
1022 if (!(dc->flags & DCF_POLLED)) in esas2r_disc_passthru_dev_addr_cb()
1025 spin_unlock_irqrestore(&a->mem_lock, flags); in esas2r_disc_passthru_dev_addr_cb()
1032 struct esas2r_adapter *a = sgc->adapter; in esas2r_disc_get_phys_addr()
1034 if (sgc->length > ESAS2R_DISC_BUF_LEN) { in esas2r_disc_get_phys_addr()
1038 *addr = a->uncached_phys in esas2r_disc_get_phys_addr()
1039 + (u64)((u8 *)a->disc_buffer - a->uncached); in esas2r_disc_get_phys_addr()
1041 return sgc->length; in esas2r_disc_get_phys_addr()
1047 struct esas2r_disc_context *dc = in esas2r_disc_dev_remove() local
1048 (struct esas2r_disc_context *)rq->interrupt_cx; in esas2r_disc_dev_remove()
1056 for (t = a->targetdb; t < a->targetdb_end; t++) { in esas2r_disc_dev_remove()
1057 if (t->new_target_state != TS_NOT_PRESENT) in esas2r_disc_dev_remove()
1060 t->new_target_state = TS_INVALID; in esas2r_disc_dev_remove()
1075 dc->state = DCS_DEV_ADD; in esas2r_disc_dev_remove()
1076 dc->curr_targ = a->targetdb; in esas2r_disc_dev_remove()
1086 struct esas2r_disc_context *dc = in esas2r_disc_dev_add() local
1087 (struct esas2r_disc_context *)rq->interrupt_cx; in esas2r_disc_dev_add()
1088 struct esas2r_target *t = dc->curr_targ; in esas2r_disc_dev_add()
1090 if (t >= a->targetdb_end) { in esas2r_disc_dev_add()
1093 dc->state = DCS_DISC_DONE; in esas2r_disc_dev_add()
1094 } else if (t->new_target_state == TS_PRESENT) { in esas2r_disc_dev_add()
1095 struct atto_vda_ae_lu *luevt = &t->lu_event; in esas2r_disc_dev_add()
1101 t->new_target_state = TS_INVALID; in esas2r_disc_dev_add()
1105 dc->curr_virt_id = esas2r_targ_get_id(t, a); in esas2r_disc_dev_add()
1107 if ((luevt->hdr.bylength >= offsetof(struct atto_vda_ae_lu, id) in esas2r_disc_dev_add()
1109 && !(luevt->dwevent & VDAAE_LU_PASSTHROUGH)) { in esas2r_disc_dev_add()
1110 dc->block_size = luevt->id.tgtlun_raid.dwblock_size; in esas2r_disc_dev_add()
1111 dc->interleave = luevt->id.tgtlun_raid.dwinterleave; in esas2r_disc_dev_add()
1113 dc->block_size = 0; in esas2r_disc_dev_add()
1114 dc->interleave = 0; in esas2r_disc_dev_add()
1119 if (luevt->dwevent & VDAAE_LU_PASSTHROUGH) { in esas2r_disc_dev_add()
1120 if (luevt->dwevent & VDAAE_LU_PHYS_ID) { in esas2r_disc_dev_add()
1121 dc->state = DCS_PT_DEV_ADDR; in esas2r_disc_dev_add()
1122 dc->dev_addr_type = ATTO_GDA_AT_PORT; in esas2r_disc_dev_add()
1123 dc->curr_phys_id = luevt->wphys_target_id; in esas2r_disc_dev_add()
1126 "luevt->dwevent does not have the " in esas2r_disc_dev_add()
1131 dc->raid_grp_name[0] = 0; in esas2r_disc_dev_add()
1133 esas2r_targ_db_add_raid(a, dc); in esas2r_disc_dev_add()
1136 esas2r_trace("curr_virt_id: %d", dc->curr_virt_id); in esas2r_disc_dev_add()
1137 esas2r_trace("curr_phys_id: %d", dc->curr_phys_id); in esas2r_disc_dev_add()
1138 esas2r_trace("dwevent: %d", luevt->dwevent); in esas2r_disc_dev_add()
1143 if (dc->state == DCS_DEV_ADD) { in esas2r_disc_dev_add()
1144 /* go to the next device. */ in esas2r_disc_dev_add()
1146 dc->curr_targ++; in esas2r_disc_dev_add()
1154 * test if they need to be modified. If a target is no longer present
1168 spin_lock_irqsave(&a->queue_lock, flags); in esas2r_disc_fix_curr_requests()
1170 list_for_each(element, &a->defer_list) { in esas2r_disc_fix_curr_requests()
1172 if (rq->vrq->scsi.function == VDA_FUNC_SCSI) { in esas2r_disc_fix_curr_requests()
1173 t = a->targetdb + rq->target_id; in esas2r_disc_fix_curr_requests()
1175 if (t->target_state == TS_PRESENT) in esas2r_disc_fix_curr_requests()
1176 rq->vrq->scsi.target_id = le16_to_cpu( in esas2r_disc_fix_curr_requests()
1177 t->virt_targ_id); in esas2r_disc_fix_curr_requests()
1179 rq->req_stat = RS_SEL; in esas2r_disc_fix_curr_requests()
1184 spin_unlock_irqrestore(&a->queue_lock, flags); in esas2r_disc_fix_curr_requests()