aic7xxx.c (51472) | aic7xxx.c (54211) |
---|---|
1/* 2 * Generic driver for the aic7xxx based adaptec SCSI controllers 3 * Product specific probe and attach routines can be found in: 4 * i386/eisa/ahc_eisa.c 27/284X and aic7770 motherboard controllers 5 * pci/ahc_pci.c 3985, 3980, 3940, 2940, aic7895, aic7890, 6 * aic7880, aic7870, aic7860, and aic7850 controllers 7 * 8 * Copyright (c) 1994, 1995, 1996, 1997, 1998, 1999 Justin T. Gibbs. 9 * All rights reserved. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions, and the following disclaimer, | 1/* 2 * Generic driver for the aic7xxx based adaptec SCSI controllers 3 * Product specific probe and attach routines can be found in: 4 * i386/eisa/ahc_eisa.c 27/284X and aic7770 motherboard controllers 5 * pci/ahc_pci.c 3985, 3980, 3940, 2940, aic7895, aic7890, 6 * aic7880, aic7870, aic7860, and aic7850 controllers 7 * 8 * Copyright (c) 1994, 1995, 1996, 1997, 1998, 1999 Justin T. Gibbs. 9 * All rights reserved. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions, and the following disclaimer, |
16 * without modification, immediately at the beginning of the file. | 16 * without modification. |
17 * 2. The name of the author may not be used to endorse or promote products 18 * derived from this software without specific prior written permission. 19 * | 17 * 2. The name of the author may not be used to endorse or promote products 18 * derived from this software without specific prior written permission. 19 * |
20 * Where this Software is combined with software released under the terms of 21 * the GNU Public License ("GPL") and the terms of the GPL would require the 22 * combined work to also be released under the terms of the GPL, the terms 23 * and conditions of this License will apply in addition to those of the 24 * GPL with the exception of any terms or conditions of this License that 25 * conflict with, or are expressly prohibited by, the GPL. | 20 * Alternatively, this software may be distributed under the terms of the 21 * the GNU Public License ("GPL"). |
26 * 27 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 31 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 * SUCH DAMAGE. 38 * | 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 27 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * |
39 * $FreeBSD: head/sys/dev/aic7xxx/aic7xxx.c 51472 1999-09-20 19:04:22Z gibbs $ | 35 * $FreeBSD: head/sys/dev/aic7xxx/aic7xxx.c 54211 1999-12-06 18:23:31Z gibbs $ |
40 */ 41/* 42 * A few notes on features of the driver. 43 * 44 * SCB paging takes advantage of the fact that devices stay disconnected 45 * from the bus a relatively long time and that while they're disconnected, 46 * having the SCBs for these transactions down on the host adapter is of 47 * little use. Instead of leaving this idle SCB down on the card we copy --- 221 unchanged lines hidden (view full) --- 269static int ahc_parse_msg(struct ahc_softc *ahc, struct cam_path *path, 270 struct ahc_devinfo *devinfo); 271static void ahc_handle_ign_wide_residue(struct ahc_softc *ahc, 272 struct ahc_devinfo *devinfo); 273static void ahc_handle_devreset(struct ahc_softc *ahc, 274 struct ahc_devinfo *devinfo, 275 cam_status status, ac_code acode, 276 char *message, | 36 */ 37/* 38 * A few notes on features of the driver. 39 * 40 * SCB paging takes advantage of the fact that devices stay disconnected 41 * from the bus a relatively long time and that while they're disconnected, 42 * having the SCBs for these transactions down on the host adapter is of 43 * little use. Instead of leaving this idle SCB down on the card we copy --- 221 unchanged lines hidden (view full) --- 265static int ahc_parse_msg(struct ahc_softc *ahc, struct cam_path *path, 266 struct ahc_devinfo *devinfo); 267static void ahc_handle_ign_wide_residue(struct ahc_softc *ahc, 268 struct ahc_devinfo *devinfo); 269static void ahc_handle_devreset(struct ahc_softc *ahc, 270 struct ahc_devinfo *devinfo, 271 cam_status status, ac_code acode, 272 char *message, |
277 int verbose_only); | 273 int verbose_level); 274#ifdef AHC_DUMP_SEQ 275static void ahc_dumpseq(struct ahc_softc *ahc); 276#endif |
278static void ahc_loadseq(struct ahc_softc *ahc); 279static int ahc_check_patch(struct ahc_softc *ahc, 280 struct patch **start_patch, 281 int start_instr, int *skip_addr); 282static void ahc_download_instr(struct ahc_softc *ahc, 283 int instrptr, u_int8_t *dconsts); 284static int ahc_match_scb(struct scb *scb, int target, char channel, 285 int lun, u_int tag, role_t role); --- 76 unchanged lines hidden (view full) --- 362 u_int tcl, int unbusy); 363 364static __inline void ahc_busy_tcl(struct ahc_softc *ahc, struct scb *scb); 365 366static __inline void ahc_freeze_ccb(union ccb* ccb); 367static __inline cam_status ahc_ccb_status(union ccb* ccb); 368static __inline void ahcsetccbstatus(union ccb* ccb, 369 cam_status status); | 277static void ahc_loadseq(struct ahc_softc *ahc); 278static int ahc_check_patch(struct ahc_softc *ahc, 279 struct patch **start_patch, 280 int start_instr, int *skip_addr); 281static void ahc_download_instr(struct ahc_softc *ahc, 282 int instrptr, u_int8_t *dconsts); 283static int ahc_match_scb(struct scb *scb, int target, char channel, 284 int lun, u_int tag, role_t role); --- 76 unchanged lines hidden (view full) --- 361 u_int tcl, int unbusy); 362 363static __inline void ahc_busy_tcl(struct ahc_softc *ahc, struct scb *scb); 364 365static __inline void ahc_freeze_ccb(union ccb* ccb); 366static __inline cam_status ahc_ccb_status(union ccb* ccb); 367static __inline void ahcsetccbstatus(union ccb* ccb, 368 cam_status status); |
370static __inline void ahc_run_tqinfifo(struct ahc_softc *ahc); 371static __inline void ahc_run_qoutfifo(struct ahc_softc *ahc); | 369static void ahc_run_tqinfifo(struct ahc_softc *ahc); 370static void ahc_run_qoutfifo(struct ahc_softc *ahc); |
372 373static __inline struct ahc_initiator_tinfo * 374 ahc_fetch_transinfo(struct ahc_softc *ahc, 375 char channel, 376 u_int our_id, u_int target, 377 struct tmode_tstate **tstate); | 371 372static __inline struct ahc_initiator_tinfo * 373 ahc_fetch_transinfo(struct ahc_softc *ahc, 374 char channel, 375 u_int our_id, u_int target, 376 struct tmode_tstate **tstate); |
378static __inline void 379 ahcfreescb(struct ahc_softc *ahc, struct scb *scb); 380static __inline struct scb * 381 ahcgetscb(struct ahc_softc *ahc); | 377static void ahcfreescb(struct ahc_softc *ahc, struct scb *scb); 378static __inline struct scb *ahcgetscb(struct ahc_softc *ahc); |
382 383static __inline u_int32_t 384ahc_hscb_busaddr(struct ahc_softc *ahc, u_int index) 385{ 386 return (ahc->scb_data->hscb_busaddr 387 + (sizeof(struct hardware_scb) * index)); 388} 389 --- 88 unchanged lines hidden (view full) --- 478 * when the roles are reversed, we pretend we are the target. 479 */ 480 if (channel == 'B') 481 our_id += 8; 482 *tstate = ahc->enabled_targets[our_id]; 483 return (&(*tstate)->transinfo[remote_id]); 484} 485 | 379 380static __inline u_int32_t 381ahc_hscb_busaddr(struct ahc_softc *ahc, u_int index) 382{ 383 return (ahc->scb_data->hscb_busaddr 384 + (sizeof(struct hardware_scb) * index)); 385} 386 --- 88 unchanged lines hidden (view full) --- 475 * when the roles are reversed, we pretend we are the target. 476 */ 477 if (channel == 'B') 478 our_id += 8; 479 *tstate = ahc->enabled_targets[our_id]; 480 return (&(*tstate)->transinfo[remote_id]); 481} 482 |
486static __inline void | 483static void |
487ahc_run_tqinfifo(struct ahc_softc *ahc) 488{ 489 struct target_cmd *cmd; 490 491 while ((cmd = &ahc->targetcmds[ahc->tqinfifonext])->cmd_valid != 0) { 492 493 /* 494 * Only advance through the queue if we --- 12 unchanged lines hidden (view full) --- 507 if ((ahc->tqinfifonext & (TQINFIFO_UPDATE_CNT-1)) == 0) { 508 pause_sequencer(ahc); 509 ahc_outb(ahc, KERNEL_TQINPOS, ahc->tqinfifonext - 1); 510 unpause_sequencer(ahc, /*unpause_always*/FALSE); 511 } 512 } 513} 514 | 484ahc_run_tqinfifo(struct ahc_softc *ahc) 485{ 486 struct target_cmd *cmd; 487 488 while ((cmd = &ahc->targetcmds[ahc->tqinfifonext])->cmd_valid != 0) { 489 490 /* 491 * Only advance through the queue if we --- 12 unchanged lines hidden (view full) --- 504 if ((ahc->tqinfifonext & (TQINFIFO_UPDATE_CNT-1)) == 0) { 505 pause_sequencer(ahc); 506 ahc_outb(ahc, KERNEL_TQINPOS, ahc->tqinfifonext - 1); 507 unpause_sequencer(ahc, /*unpause_always*/FALSE); 508 } 509 } 510} 511 |
515static __inline void | 512static void |
516ahc_run_qoutfifo(struct ahc_softc *ahc) 517{ 518 struct scb *scb; 519 u_int scb_index; 520 521 while (ahc->qoutfifo[ahc->qoutfifonext] != SCB_LIST_NULL) { 522 scb_index = ahc->qoutfifo[ahc->qoutfifonext]; 523 ahc->qoutfifo[ahc->qoutfifonext++] = SCB_LIST_NULL; --- 20 unchanged lines hidden (view full) --- 544 } 545} 546 547 548/* 549 * An scb (and hence an scb entry on the board) is put onto the 550 * free list. 551 */ | 513ahc_run_qoutfifo(struct ahc_softc *ahc) 514{ 515 struct scb *scb; 516 u_int scb_index; 517 518 while (ahc->qoutfifo[ahc->qoutfifonext] != SCB_LIST_NULL) { 519 scb_index = ahc->qoutfifo[ahc->qoutfifonext]; 520 ahc->qoutfifo[ahc->qoutfifonext++] = SCB_LIST_NULL; --- 20 unchanged lines hidden (view full) --- 541 } 542} 543 544 545/* 546 * An scb (and hence an scb entry on the board) is put onto the 547 * free list. 548 */ |
552static __inline void | 549static void |
553ahcfreescb(struct ahc_softc *ahc, struct scb *scb) 554{ 555 struct hardware_scb *hscb; 556 int opri; 557 558 hscb = scb->hscb; 559 560 opri = splcam(); --- 415 unchanged lines hidden (view full) --- 976} 977 978int 979ahc_reset(struct ahc_softc *ahc) 980{ 981 u_int sblkctl; 982 int wait; 983 | 550ahcfreescb(struct ahc_softc *ahc, struct scb *scb) 551{ 552 struct hardware_scb *hscb; 553 int opri; 554 555 hscb = scb->hscb; 556 557 opri = splcam(); --- 415 unchanged lines hidden (view full) --- 973} 974 975int 976ahc_reset(struct ahc_softc *ahc) 977{ 978 u_int sblkctl; 979 int wait; 980 |
981#ifdef AHC_DUMP_SEQ 982 ahc_dumpseq(ahc); 983#endif |
|
984 ahc_outb(ahc, HCNTRL, CHIPRST | ahc->pause); 985 /* 986 * Ensure that the reset has finished 987 */ 988 wait = 1000; | 984 ahc_outb(ahc, HCNTRL, CHIPRST | ahc->pause); 985 /* 986 * Ensure that the reset has finished 987 */ 988 wait = 1000; |
989 while (--wait && !(ahc_inb(ahc, HCNTRL) & CHIPRSTACK)) | 989 do { |
990 DELAY(1000); | 990 DELAY(1000); |
991 } while (--wait && !(ahc_inb(ahc, HCNTRL) & CHIPRSTACK)); 992 |
|
991 if (wait == 0) { 992 printf("%s: WARNING - Failed chip reset! " 993 "Trying to initialize anyway.\n", ahc_name(ahc)); 994 } 995 ahc_outb(ahc, HCNTRL, ahc->pause); 996 997 /* Determine channel configuration */ 998 sblkctl = ahc_inb(ahc, SBLKCTL) & (SELBUSB|SELWIDE); --- 1571 unchanged lines hidden (view full) --- 2570 case MSG_ABORT_TAG: 2571 tag = scb->hscb->tag; 2572 /* FALLTRHOUGH */ 2573 case MSG_ABORT: 2574 xpt_print_path(scb->ccb->ccb_h.path); 2575 printf("SCB %d - Abort %s Completed.\n", 2576 scb->hscb->tag, tag == SCB_LIST_NULL ? 2577 "" : "Tag"); | 993 if (wait == 0) { 994 printf("%s: WARNING - Failed chip reset! " 995 "Trying to initialize anyway.\n", ahc_name(ahc)); 996 } 997 ahc_outb(ahc, HCNTRL, ahc->pause); 998 999 /* Determine channel configuration */ 1000 sblkctl = ahc_inb(ahc, SBLKCTL) & (SELBUSB|SELWIDE); --- 1571 unchanged lines hidden (view full) --- 2572 case MSG_ABORT_TAG: 2573 tag = scb->hscb->tag; 2574 /* FALLTRHOUGH */ 2575 case MSG_ABORT: 2576 xpt_print_path(scb->ccb->ccb_h.path); 2577 printf("SCB %d - Abort %s Completed.\n", 2578 scb->hscb->tag, tag == SCB_LIST_NULL ? 2579 "" : "Tag"); |
2578 if ((scb->flags & SCB_RECOVERY_SCB) != 0) { 2579 ahcsetccbstatus(scb->ccb, 2580 CAM_REQ_ABORTED); 2581 ahc_done(ahc, scb); 2582 } | 2580 ahc_abort_scbs(ahc, target, channel, 2581 TCL_LUN(saved_tcl), tag, 2582 ROLE_INITIATOR, 2583 CAM_REQ_ABORTED); |
2583 printerror = 0; 2584 break; 2585 case MSG_BUS_DEV_RESET: 2586 { 2587 struct ahc_devinfo devinfo; 2588 | 2584 printerror = 0; 2585 break; 2586 case MSG_BUS_DEV_RESET: 2587 { 2588 struct ahc_devinfo devinfo; 2589 |
2590 /* 2591 * Don't mark the user's request for this BDR 2592 * as completing with CAM_BDR_SENT. CAM3 2593 * specifies CAM_REQ_CMP. 2594 */ 2595 if (scb != NULL 2596 && scb->ccb->ccb_h.func_code == XPT_RESET_DEV 2597 && ahc_match_scb(scb, target, channel, 2598 TCL_LUN(saved_tcl), 2599 ROLE_INITIATOR, 2600 SCB_LIST_NULL)) { 2601 ahcsetccbstatus(scb->ccb, CAM_REQ_CMP); 2602 } |
|
2589 ahc_compile_devinfo(&devinfo, 2590 initiator_role_id, 2591 target, 2592 TCL_LUN(saved_tcl), 2593 channel, 2594 ROLE_INITIATOR); 2595 ahc_handle_devreset(ahc, &devinfo, 2596 CAM_BDR_SENT, AC_SENT_BDR, 2597 "Bus Device Reset", | 2603 ahc_compile_devinfo(&devinfo, 2604 initiator_role_id, 2605 target, 2606 TCL_LUN(saved_tcl), 2607 channel, 2608 ROLE_INITIATOR); 2609 ahc_handle_devreset(ahc, &devinfo, 2610 CAM_BDR_SENT, AC_SENT_BDR, 2611 "Bus Device Reset", |
2598 /*verbose_only*/FALSE); | 2612 /*verbose_level*/0); |
2599 printerror = 0; 2600 break; 2601 } 2602 default: 2603 break; 2604 } 2605 } 2606 if (printerror != 0) { --- 44 unchanged lines hidden (view full) --- 2651 "valid during SELTO scb(%d, %d)\n", 2652 ahc_name(ahc), scbptr, scb_index); 2653 } else { 2654 struct ahc_devinfo devinfo; 2655 2656 ahc_scb_devinfo(ahc, &devinfo, scb); 2657 ahc_handle_devreset(ahc, &devinfo, CAM_SEL_TIMEOUT, 2658 /*ac_code*/0, "Selection Timeout", | 2613 printerror = 0; 2614 break; 2615 } 2616 default: 2617 break; 2618 } 2619 } 2620 if (printerror != 0) { --- 44 unchanged lines hidden (view full) --- 2665 "valid during SELTO scb(%d, %d)\n", 2666 ahc_name(ahc), scbptr, scb_index); 2667 } else { 2668 struct ahc_devinfo devinfo; 2669 2670 ahc_scb_devinfo(ahc, &devinfo, scb); 2671 ahc_handle_devreset(ahc, &devinfo, CAM_SEL_TIMEOUT, 2672 /*ac_code*/0, "Selection Timeout", |
2659 /*verbose_only*/TRUE); | 2673 /*verbose_level*/2); |
2660 } 2661 /* Stop the selection */ 2662 ahc_outb(ahc, SCSISEQ, 0); 2663 2664 /* No more pending messages */ 2665 ahc_clear_msg_state(ahc); 2666 2667 /* --- 109 unchanged lines hidden (view full) --- 2777 dowide = tinfo->current.width != tinfo->goal.width; 2778 dosync = tinfo->current.period != tinfo->goal.period; 2779 2780 if (!dowide && !dosync) { 2781 dowide = tinfo->goal.width != MSG_EXT_WDTR_BUS_8_BIT; 2782 dosync = tinfo->goal.period != 0; 2783 } 2784 | 2674 } 2675 /* Stop the selection */ 2676 ahc_outb(ahc, SCSISEQ, 0); 2677 2678 /* No more pending messages */ 2679 ahc_clear_msg_state(ahc); 2680 2681 /* --- 109 unchanged lines hidden (view full) --- 2791 dowide = tinfo->current.width != tinfo->goal.width; 2792 dosync = tinfo->current.period != tinfo->goal.period; 2793 2794 if (!dowide && !dosync) { 2795 dowide = tinfo->goal.width != MSG_EXT_WDTR_BUS_8_BIT; 2796 dosync = tinfo->goal.period != 0; 2797 } 2798 |
2785 if (dowide) | 2799 if (dowide) { |
2786 ahc_construct_wdtr(ahc, tinfo->goal.width); | 2800 ahc_construct_wdtr(ahc, tinfo->goal.width); |
2787 else if (dosync) { | 2801 } else if (dosync) { |
2788 struct ahc_syncrate *rate; 2789 u_int period; 2790 u_int offset; 2791 2792 period = tinfo->goal.period; 2793 rate = ahc_devlimited_syncrate(ahc, &period); 2794 offset = tinfo->goal.offset; 2795 ahc_validate_offset(ahc, rate, &offset, --- 106 unchanged lines hidden (view full) --- 2902 2903 /* Might be necessary */ 2904 last_msg = ahc_inb(ahc, LAST_MSG); 2905 2906 if (ahc_sent_msg(ahc, MSG_EXT_WDTR, /*full*/FALSE)) { 2907 struct ahc_initiator_tinfo *tinfo; 2908 struct tmode_tstate *tstate; 2909 | 2802 struct ahc_syncrate *rate; 2803 u_int period; 2804 u_int offset; 2805 2806 period = tinfo->goal.period; 2807 rate = ahc_devlimited_syncrate(ahc, &period); 2808 offset = tinfo->goal.offset; 2809 ahc_validate_offset(ahc, rate, &offset, --- 106 unchanged lines hidden (view full) --- 2916 2917 /* Might be necessary */ 2918 last_msg = ahc_inb(ahc, LAST_MSG); 2919 2920 if (ahc_sent_msg(ahc, MSG_EXT_WDTR, /*full*/FALSE)) { 2921 struct ahc_initiator_tinfo *tinfo; 2922 struct tmode_tstate *tstate; 2923 |
2910 /* note 8bit xfers and clear flag */ | 2924 /* note 8bit xfers */ |
2911 printf("%s:%c:%d: refuses WIDE negotiation. Using " 2912 "8bit transfers\n", ahc_name(ahc), 2913 devinfo->channel, devinfo->target); 2914 ahc_set_width(ahc, devinfo, scb->ccb->ccb_h.path, 2915 MSG_EXT_WDTR_BUS_8_BIT, 2916 AHC_TRANS_ACTIVE|AHC_TRANS_GOAL, 2917 /*paused*/TRUE); | 2925 printf("%s:%c:%d: refuses WIDE negotiation. Using " 2926 "8bit transfers\n", ahc_name(ahc), 2927 devinfo->channel, devinfo->target); 2928 ahc_set_width(ahc, devinfo, scb->ccb->ccb_h.path, 2929 MSG_EXT_WDTR_BUS_8_BIT, 2930 AHC_TRANS_ACTIVE|AHC_TRANS_GOAL, 2931 /*paused*/TRUE); |
2918 ahc_set_syncrate(ahc, devinfo, scb->ccb->ccb_h.path, 2919 /*syncrate*/NULL, /*period*/0, 2920 /*offset*/0, AHC_TRANS_ACTIVE, 2921 /*paused*/TRUE); | 2932 /* 2933 * No need to clear the sync rate. If the target 2934 * did not accept the command, our syncrate is 2935 * unaffected. If the target started the negotiation, 2936 * but rejected our response, we already cleared the 2937 * sync rate before sending our WDTR. 2938 */ |
2922 tinfo = ahc_fetch_transinfo(ahc, devinfo->channel, 2923 devinfo->our_scsiid, 2924 devinfo->target, &tstate); 2925 if (tinfo->goal.period) { 2926 u_int period; 2927 2928 /* Start the sync negotiation */ 2929 period = tinfo->goal.period; --- 176 unchanged lines hidden (view full) --- 3106 /* 3107 * If this message illicited a response, 3108 * assert ATN so the target takes us to the 3109 * message out phase. 3110 */ 3111 if (ahc->msgout_len != 0) 3112 ahc_outb(ahc, SCSISIGO, 3113 ahc_inb(ahc, SCSISIGO) | ATNO); | 2939 tinfo = ahc_fetch_transinfo(ahc, devinfo->channel, 2940 devinfo->our_scsiid, 2941 devinfo->target, &tstate); 2942 if (tinfo->goal.period) { 2943 u_int period; 2944 2945 /* Start the sync negotiation */ 2946 period = tinfo->goal.period; --- 176 unchanged lines hidden (view full) --- 3123 /* 3124 * If this message illicited a response, 3125 * assert ATN so the target takes us to the 3126 * message out phase. 3127 */ 3128 if (ahc->msgout_len != 0) 3129 ahc_outb(ahc, SCSISIGO, 3130 ahc_inb(ahc, SCSISIGO) | ATNO); |
3114 } | 3131 } else 3132 ahc->msgin_index++; |
3115 3116 /* Ack the byte */ 3117 ahc_outb(ahc, CLRSINT1, CLRREQINIT); 3118 ahc_inb(ahc, SCSIDATL); | 3133 3134 /* Ack the byte */ 3135 ahc_outb(ahc, CLRSINT1, CLRREQINIT); 3136 ahc_inb(ahc, SCSIDATL); |
3119 ahc->msgin_index++; | |
3120 break; 3121 } 3122 case MSG_TYPE_TARGET_MSGIN: 3123 { 3124 int msgdone; 3125 int msgout_request; 3126 3127 if (ahc->msgout_len == 0) --- 396 unchanged lines hidden (view full) --- 3524 break; 3525 } 3526 break; 3527 } 3528 case MSG_BUS_DEV_RESET: 3529 ahc_handle_devreset(ahc, devinfo, 3530 CAM_BDR_SENT, AC_SENT_BDR, 3531 "Bus Device Reset Received", | 3137 break; 3138 } 3139 case MSG_TYPE_TARGET_MSGIN: 3140 { 3141 int msgdone; 3142 int msgout_request; 3143 3144 if (ahc->msgout_len == 0) --- 396 unchanged lines hidden (view full) --- 3541 break; 3542 } 3543 break; 3544 } 3545 case MSG_BUS_DEV_RESET: 3546 ahc_handle_devreset(ahc, devinfo, 3547 CAM_BDR_SENT, AC_SENT_BDR, 3548 "Bus Device Reset Received", |
3532 /*verbose_only*/FALSE); | 3549 /*verbose_level*/0); |
3533 restart_sequencer(ahc); 3534 done = MSGLOOP_TERMINATED; 3535 break; 3536 case MSG_ABORT_TAG: 3537 case MSG_ABORT: 3538 case MSG_CLEAR_QUEUE: 3539 /* Target mode messages */ 3540 if (devinfo->role != ROLE_TARGET) { --- 127 unchanged lines hidden (view full) --- 3668 ahc_outb(ahc, SHADDR, data_addr); 3669 } 3670 } 3671} 3672 3673static void 3674ahc_handle_devreset(struct ahc_softc *ahc, struct ahc_devinfo *devinfo, 3675 cam_status status, ac_code acode, char *message, | 3550 restart_sequencer(ahc); 3551 done = MSGLOOP_TERMINATED; 3552 break; 3553 case MSG_ABORT_TAG: 3554 case MSG_ABORT: 3555 case MSG_CLEAR_QUEUE: 3556 /* Target mode messages */ 3557 if (devinfo->role != ROLE_TARGET) { --- 127 unchanged lines hidden (view full) --- 3685 ahc_outb(ahc, SHADDR, data_addr); 3686 } 3687 } 3688} 3689 3690static void 3691ahc_handle_devreset(struct ahc_softc *ahc, struct ahc_devinfo *devinfo, 3692 cam_status status, ac_code acode, char *message, |
3676 int verbose_only) | 3693 int verbose_level) |
3677{ 3678 struct cam_path *path; 3679 int found; 3680 int error; 3681 struct tmode_tstate* tstate; 3682 u_int lun; 3683 3684 --- 35 unchanged lines hidden (view full) --- 3720 3721 if (error == CAM_REQ_CMP && acode != 0) 3722 xpt_async(AC_SENT_BDR, path, NULL); 3723 3724 if (error == CAM_REQ_CMP) 3725 xpt_free_path(path); 3726 3727 if (message != NULL | 3694{ 3695 struct cam_path *path; 3696 int found; 3697 int error; 3698 struct tmode_tstate* tstate; 3699 u_int lun; 3700 3701 --- 35 unchanged lines hidden (view full) --- 3737 3738 if (error == CAM_REQ_CMP && acode != 0) 3739 xpt_async(AC_SENT_BDR, path, NULL); 3740 3741 if (error == CAM_REQ_CMP) 3742 xpt_free_path(path); 3743 3744 if (message != NULL |
3728 && (verbose_only == 0 || bootverbose != 0)) | 3745 && (verbose_level <= bootverbose)) |
3729 printf("%s: %s on %c:%d. %d SCBs aborted\n", ahc_name(ahc), 3730 message, devinfo->channel, devinfo->target, found); 3731} 3732 3733/* 3734 * We have an scb which has been processed by the 3735 * adaptor, now we look to see how the operation 3736 * went. --- 65 unchanged lines hidden (view full) --- 3802 /* 3803 * Ensure that we didn't put a second instance of this 3804 * SCB into the QINFIFO. 3805 */ 3806 ahc_search_qinfifo(ahc, SCB_TARGET(scb), SCB_CHANNEL(scb), 3807 SCB_LUN(scb), scb->hscb->tag, 3808 ROLE_INITIATOR, /*status*/0, 3809 SEARCH_REMOVE); | 3746 printf("%s: %s on %c:%d. %d SCBs aborted\n", ahc_name(ahc), 3747 message, devinfo->channel, devinfo->target, found); 3748} 3749 3750/* 3751 * We have an scb which has been processed by the 3752 * adaptor, now we look to see how the operation 3753 * went. --- 65 unchanged lines hidden (view full) --- 3819 /* 3820 * Ensure that we didn't put a second instance of this 3821 * SCB into the QINFIFO. 3822 */ 3823 ahc_search_qinfifo(ahc, SCB_TARGET(scb), SCB_CHANNEL(scb), 3824 SCB_LUN(scb), scb->hscb->tag, 3825 ROLE_INITIATOR, /*status*/0, 3826 SEARCH_REMOVE); |
3810 if (ahc_ccb_status(ccb) == CAM_BDR_SENT) | 3827 if (ahc_ccb_status(ccb) == CAM_BDR_SENT 3828 || ahc_ccb_status(ccb) == CAM_REQ_ABORTED) |
3811 ahcsetccbstatus(ccb, CAM_CMD_TIMEOUT); 3812 xpt_print_path(ccb->ccb_h.path); 3813 printf("no longer in timeout, status = %x\n", 3814 ccb->ccb_h.status); 3815 } 3816 3817 /* Don't clobber any existing error state */ 3818 if (ahc_ccb_status(ccb) == CAM_REQ_INPROG) { --- 1340 unchanged lines hidden (view full) --- 5159 SLIST_INSERT_HEAD(&ahc->scb_data->free_scbs, next_scb, links); 5160 segs += AHC_NSEG; 5161 physaddr += (AHC_NSEG * sizeof(struct ahc_dma_seg)); 5162 next_scb++; 5163 ahc->scb_data->numscbs++; 5164 } 5165} 5166 | 3829 ahcsetccbstatus(ccb, CAM_CMD_TIMEOUT); 3830 xpt_print_path(ccb->ccb_h.path); 3831 printf("no longer in timeout, status = %x\n", 3832 ccb->ccb_h.status); 3833 } 3834 3835 /* Don't clobber any existing error state */ 3836 if (ahc_ccb_status(ccb) == CAM_REQ_INPROG) { --- 1340 unchanged lines hidden (view full) --- 5177 SLIST_INSERT_HEAD(&ahc->scb_data->free_scbs, next_scb, links); 5178 segs += AHC_NSEG; 5179 physaddr += (AHC_NSEG * sizeof(struct ahc_dma_seg)); 5180 next_scb++; 5181 ahc->scb_data->numscbs++; 5182 } 5183} 5184 |
5185#ifdef AHC_DUMP_SEQ |
|
5167static void | 5186static void |
5187ahc_dumpseq(struct ahc_softc* ahc) 5188{ 5189 int i; 5190 int max_prog; 5191 5192 if ((ahc->chip & AHC_BUS_MASK) < AHC_PCI) 5193 max_prog = 448; 5194 else if ((ahc->features & AHC_ULTRA2) != 0) 5195 max_prog = 768; 5196 else 5197 max_prog = 512; 5198 5199 ahc_outb(ahc, SEQCTL, PERRORDIS|FAILDIS|FASTMODE|LOADRAM); 5200 ahc_outb(ahc, SEQADDR0, 0); 5201 ahc_outb(ahc, SEQADDR1, 0); 5202 for (i = 0; i < max_prog; i++) { 5203 u_int8_t ins_bytes[4]; 5204 5205 ahc_insb(ahc, SEQRAM, ins_bytes, 4); 5206 printf("0x%2.2x%2.2x%2.2x%2.2x\n", 5207 ins_bytes[0], 5208 ins_bytes[1], 5209 ins_bytes[2], 5210 ins_bytes[3]); 5211 } 5212} 5213#endif 5214 5215static void |
|
5168ahc_loadseq(struct ahc_softc *ahc) 5169{ 5170 struct patch *cur_patch; 5171 int i; 5172 int downloaded; 5173 int skip_addr; 5174 u_int8_t download_consts[4]; 5175 --- 426 unchanged lines hidden (view full) --- 5602 */ 5603 scb->hscb->control |= MK_MESSAGE; 5604 scb->flags |= SCB_QUEUED_MSG 5605 | SCB_DEVICE_RESET; 5606 5607 /* 5608 * Remove this SCB from the disconnected 5609 * list so that a reconnect at this point | 5216ahc_loadseq(struct ahc_softc *ahc) 5217{ 5218 struct patch *cur_patch; 5219 int i; 5220 int downloaded; 5221 int skip_addr; 5222 u_int8_t download_consts[4]; 5223 --- 426 unchanged lines hidden (view full) --- 5650 */ 5651 scb->hscb->control |= MK_MESSAGE; 5652 scb->flags |= SCB_QUEUED_MSG 5653 | SCB_DEVICE_RESET; 5654 5655 /* 5656 * Remove this SCB from the disconnected 5657 * list so that a reconnect at this point |
5610 * causes a BDR. | 5658 * causes a BDR or abort. |
5611 */ 5612 ahc_search_disc_list(ahc, target, channel, lun, 5613 scb->hscb->tag); 5614 ahc_index_busy_tcl(ahc, scb->hscb->tcl, 5615 /*unbusy*/TRUE); 5616 5617 /* 5618 * Actually re-queue this SCB in case we can --- 674 unchanged lines hidden (view full) --- 6293 scb->ccb->csio.sense_resid = resid; 6294 } 6295 } 6296 6297 /* 6298 * Clean out the residual information in this SCB for its 6299 * next consumer. 6300 */ | 5659 */ 5660 ahc_search_disc_list(ahc, target, channel, lun, 5661 scb->hscb->tag); 5662 ahc_index_busy_tcl(ahc, scb->hscb->tcl, 5663 /*unbusy*/TRUE); 5664 5665 /* 5666 * Actually re-queue this SCB in case we can --- 674 unchanged lines hidden (view full) --- 6341 scb->ccb->csio.sense_resid = resid; 6342 } 6343 } 6344 6345 /* 6346 * Clean out the residual information in this SCB for its 6347 * next consumer. 6348 */ |
6301 hscb->residual_data_count[0] = 0; 6302 hscb->residual_data_count[1] = 0; 6303 hscb->residual_data_count[2] = 0; | |
6304 hscb->residual_SG_count = 0; 6305 6306#ifdef AHC_DEBUG 6307 if (ahc_debug & AHC_SHOWMISC) { 6308 sc_print_addr(xs->sc_link); 6309 printf("Handled Residual of %ld bytes\n" ,xs->resid); 6310 } 6311#endif --- 265 unchanged lines hidden --- | 6349 hscb->residual_SG_count = 0; 6350 6351#ifdef AHC_DEBUG 6352 if (ahc_debug & AHC_SHOWMISC) { 6353 sc_print_addr(xs->sc_link); 6354 printf("Handled Residual of %ld bytes\n" ,xs->resid); 6355 } 6356#endif --- 265 unchanged lines hidden --- |