1/* $FreeBSD: head/sys/dev/isp/isp.c 65140 2000-08-27 23:38:44Z mjacob $ */ |
2/* 3 * Machine and OS Independent (well, as best as possible) 4 * code for the Qlogic ISP SCSI adapters. 5 * 6 * Copyright (c) 1997, 1998, 1999 by Matthew Jacob 7 * NASA/Ames Research Center 8 * All rights reserved. 9 * --- 580 unchanged lines hidden (view full) --- 590 */ 591 mbs.param[0] = MBOX_VERIFY_CHECKSUM; 592 mbs.param[1] = ISP_CODE_ORG; 593 isp_mboxcmd(isp, &mbs, MBLOGNONE); 594 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { 595 isp_prt(isp, ISP_LOGERR, "Ram Checksum Failure"); 596 return; 597 } |
598 isp->isp_loaded_fw = 1; |
599 } else { |
600 isp->isp_loaded_fw = 0; |
601 isp_prt(isp, ISP_LOGDEBUG2, "skipping f/w download"); 602 } 603 604 /* 605 * Now start it rolling. 606 * 607 * If we didn't actually download f/w, 608 * we still need to (re)start it. --- 138 unchanged lines hidden (view full) --- 747 sdp_chan1++; 748 } 749 750 /* First do overall per-card settings. */ 751 752 /* 753 * If we have fast memory timing enabled, turn it on. 754 */ |
755 if (sdp_chan0->isp_fast_mttr) { |
756 ISP_WRITE(isp, RISC_MTR, 0x1313); 757 } 758 759 /* 760 * Set Retry Delay and Count. 761 * You set both channels at the same time. 762 */ 763 mbs.param[0] = MBOX_SET_RETRY_COUNT; --- 156 unchanged lines hidden (view full) --- 920 */ 921 for (tgt = 0; tgt < MAX_TARGETS; tgt++) { 922 int lun; 923 u_int16_t sdf; 924 925 if (sdp->isp_devparam[tgt].dev_enable == 0) { 926 continue; 927 } |
928 sdf = DPARM_SAFE_DFLT; |
929 /* |
930 * It is not quite clear when this changed over so that 931 * we could force narrow and async for 1000/1020 cards, 932 * but assume that this is only the case for loaded 933 * firmware. |
934 */ |
935 if (isp->isp_loaded_fw) { 936 sdf |= DPARM_NARROW | DPARM_ASYNC; |
937 } 938 mbs.param[0] = MBOX_SET_TARGET_PARAMS; 939 mbs.param[1] = (tgt << 8) | (channel << 15); 940 mbs.param[2] = sdf; |
941 if ((sdf & DPARM_SYNC) == 0) { 942 mbs.param[3] = 0; 943 } else { 944 mbs.param[3] = 945 (sdp->isp_devparam[tgt].sync_offset << 8) | 946 (sdp->isp_devparam[tgt].sync_period); 947 } |
948 isp_mboxcmd(isp, &mbs, MBLOGALL); 949 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { 950 sdf = DPARM_SAFE_DFLT; 951 mbs.param[0] = MBOX_SET_TARGET_PARAMS; 952 mbs.param[1] = (tgt << 8) | (channel << 15); 953 mbs.param[2] = sdf; |
954 mbs.param[3] = 0; |
955 isp_mboxcmd(isp, &mbs, MBLOGALL); 956 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { 957 continue; 958 } 959 } |
960 |
961 /* |
962 * We don't update any information directly from the f/w 963 * because we need to run at least one command to cause a 964 * new state to be latched up. So, we just assume that we 965 * converge to the values we just had set. 966 * |
967 * Ensure that we don't believe tagged queuing is enabled yet. 968 * It turns out that sometimes the ISP just ignores our 969 * attempts to set parameters for devices that it hasn't 970 * seen yet. 971 */ |
972 sdp->isp_devparam[tgt].cur_dflags = sdf & ~DPARM_TQING; |
973 for (lun = 0; lun < (int) isp->isp_maxluns; lun++) { 974 mbs.param[0] = MBOX_SET_DEV_QUEUE_PARAMS; 975 mbs.param[1] = (channel << 15) | (tgt << 8) | lun; 976 mbs.param[2] = sdp->isp_max_queue_depth; 977 mbs.param[3] = sdp->isp_devparam[tgt].exc_throttle; 978 isp_mboxcmd(isp, &mbs, MBLOGALL); 979 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { 980 break; 981 } 982 } 983 } |
984 for (tgt = 0; tgt < MAX_TARGETS; tgt++) { 985 if (sdp->isp_devparam[tgt].dev_refresh) { 986 isp->isp_sendmarker |= (1 << channel); 987 isp->isp_update |= (1 << channel); 988 break; 989 } 990 } |
991} 992 993/* 994 * Fibre Channel specific initialization. 995 * 996 * Locks are held before coming here. 997 */ 998static void --- 7 unchanged lines hidden (view full) --- 1006 1007 fcp = isp->isp_param; 1008 1009 loopid = DEFAULT_LOOPID(isp); 1010 icbp = (isp_icb_t *) fcp->isp_scratch; 1011 MEMZERO(icbp, sizeof (*icbp)); 1012 1013 icbp->icb_version = ICB_VERSION1; |
1014 |
1015 /* |
1016 * Firmware Options are either retrieved from NVRAM or 1017 * are patched elsewhere. We check them for sanity here 1018 * and make changes based on board revision, but otherwise 1019 * let others decide policy. 1020 */ 1021 1022 /* |
1023 * If this is a 2100 < revision 5, we have to turn off FAIRNESS. 1024 */ 1025 if ((isp->isp_type == ISP_HA_FC_2100) && isp->isp_revision < 5) { 1026 fcp->isp_fwoptions &= ~ICBOPT_FAIRNESS; 1027 } |
1028 |
1029 /* 1030 * We have to use FULL LOGIN even though it resets the loop too much 1031 * because otherwise port database entries don't get updated after 1032 * a LIP- this is a known f/w bug for 2100 f/w less than 1.17.0. 1033 */ 1034 if (ISP_FW_REVX(isp->isp_fwrev) < ISP_FW_REV(1, 17, 0)) { 1035 fcp->isp_fwoptions |= ICBOPT_FULL_LOGIN; 1036 } |
1037 1038 /* |
1039 * Insist on Port Database Update Async notifications 1040 */ 1041 fcp->isp_fwoptions |= ICBOPT_PDBCHANGE_AE; 1042 1043 /* |
1044 * We don't set ICBOPT_PORTNAME because we want our 1045 * Node Name && Port Names to be distinct. 1046 */ 1047 1048 icbp->icb_fwoptions = fcp->isp_fwoptions; 1049 icbp->icb_maxfrmlen = fcp->isp_maxfrmlen; 1050 if (icbp->icb_maxfrmlen < ICB_MIN_FRMLEN || 1051 icbp->icb_maxfrmlen > ICB_MAX_FRMLEN) { --- 13 unchanged lines hidden (view full) --- 1065 isp_prt(isp, ISP_LOGERR, 1066 "bad execution throttle of %d- using 16", 1067 fcp->isp_execthrottle); 1068 icbp->icb_execthrottle = ICB_DFLT_THROTTLE; 1069 } 1070 icbp->icb_retry_delay = fcp->isp_retry_delay; 1071 icbp->icb_retry_count = fcp->isp_retry_count; 1072 icbp->icb_hardaddr = loopid; |
1073 /* 1074 * Right now we just set extended options to prefer point-to-point 1075 * over loop based upon some soft config options. 1076 */ |
1077 if (IS_2200(isp)) { 1078 icbp->icb_fwoptions |= ICBOPT_EXTENDED; 1079 /* 1080 * Prefer or force Point-To-Point instead Loop? 1081 */ 1082 if (isp->isp_confopts & ISP_CFG_NPORT) 1083 icbp->icb_xfwoptions = ICBXOPT_PTP_2_LOOP; 1084 else 1085 icbp->icb_xfwoptions = ICBXOPT_LOOP_2_PTP; 1086 } |
1087 icbp->icb_logintime = 60; /* 60 second login timeout */ 1088 1089 if (fcp->isp_nodewwn) { 1090 MAKE_NODE_NAME_FROM_WWN(icbp->icb_nodename, fcp->isp_nodewwn); 1091 MAKE_NODE_NAME_FROM_WWN(icbp->icb_portname, fcp->isp_portwwn); 1092 } else { 1093 fcp->isp_fwoptions &= ~(ICBOPT_USE_PORTNAME|ICBOPT_FULL_LOGIN); 1094 } 1095 icbp->icb_rqstqlen = RQUEST_QUEUE_LEN(isp); 1096 icbp->icb_rsltqlen = RESULT_QUEUE_LEN(isp); 1097 icbp->icb_rqstaddr[RQRSP_ADDR0015] = DMA_LSW(isp->isp_rquest_dma); 1098 icbp->icb_rqstaddr[RQRSP_ADDR1631] = DMA_MSW(isp->isp_rquest_dma); 1099 icbp->icb_respaddr[RQRSP_ADDR0015] = DMA_LSW(isp->isp_result_dma); 1100 icbp->icb_respaddr[RQRSP_ADDR1631] = DMA_MSW(isp->isp_result_dma); |
1101 isp_prt(isp, ISP_LOGDEBUG1, 1102 "isp_fibre_init: fwoptions 0x%x", fcp->isp_fwoptions); |
1103 ISP_SWIZZLE_ICB(isp, icbp); 1104 1105 /* 1106 * Do this *before* initializing the firmware. 1107 */ 1108 isp_mark_getpdb_all(isp); 1109 fcp->isp_fwstate = FW_CONFIG_WAIT; 1110 fcp->isp_loopstate = LOOP_NIL; --- 155 unchanged lines hidden (view full) --- 1266 enano = NANOTIME_SUB(&hrb, &hra); 1267 1268 /* 1269 * If the elapsed time is less than 1 millisecond, 1270 * delay a period of time up to that millisecond of 1271 * waiting. 1272 */ 1273 isp_prt(isp, ISP_LOGDEBUG3, "usec%d: 0x%lx->0x%lx enano %u", |
1274 count, (long) GET_NANOSEC(&hra), (long) GET_NANOSEC(&hrb), 1275 enano); |
1276 1277 /* 1278 * This peculiar code is an attempt to try and avoid 1279 * invoking u_int64_t math support functions for some 1280 * platforms where linkage is a problem. 1281 */ 1282 if (enano < (1000 * 1000)) { 1283 count += 1000; --- 912 unchanged lines hidden (view full) --- 2196 /* 2197 * Fibre Channel always requires some kind of tag. 2198 * The Qlogic drivers seem be happy not to use a tag, 2199 * but this breaks for some devices (IBM drives). 2200 */ 2201 if (XS_TAG_P(xs)) { 2202 t2reqp->req_flags = XS_TAG_TYPE(xs); 2203 } else { |
2204 /* 2205 * If we don't know what tag to use, use HEAD OF QUEUE 2206 * for Request Sense or Ordered (for safety's sake). 2207 */ |
2208 if (XS_CDBP(xs)[0] == 0x3) /* REQUEST SENSE */ 2209 t2reqp->req_flags = REQFLAG_HTAG; 2210 else 2211 t2reqp->req_flags = REQFLAG_OTAG; 2212 } 2213 } else { 2214 sdparam *sdp = (sdparam *)isp->isp_param; 2215 if ((sdp->isp_devparam[target].cur_dflags & DPARM_TQING) && --- 143 unchanged lines hidden (view full) --- 2359 (bus << 15) | (XS_TGT(xs) << 8) | XS_LUN(xs); 2360 } 2361 mbs.param[3] = handle >> 16; 2362 mbs.param[2] = handle & 0xffff; 2363 isp_mboxcmd(isp, &mbs, MBLOGALL & ~MBOX_COMMAND_ERROR); 2364 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) { 2365 return (0); 2366 } |
2367 /* 2368 * XXX: Look for command in the REQUEST QUEUE. That is, 2369 * XXX: It hasen't been picked up by firmware yet. 2370 */ |
2371 break; 2372 2373 case ISPCTL_UPDATE_PARAMS: 2374 isp_update(isp); 2375 return (0); 2376 2377 case ISPCTL_FCLINK_TEST: 2378 if (IS_FC(isp)) { 2379 int usdelay = (arg)? *((int *) arg) : 250000; 2380 return (isp_fclink_test(isp, usdelay)); 2381 } 2382 break; 2383 2384 case ISPCTL_PDB_SYNC: 2385 if (IS_FC(isp)) { 2386 return (isp_pdb_sync(isp, -1)); 2387 } 2388 break; |
2389#ifdef ISP_TARGET_MODE 2390 case ISPCTL_TOGGLE_TMODE: |
2391 { 2392 int ena = *(int *)arg; |
2393 if (IS_SCSI(isp)) { |
2394 mbs.param[0] = MBOX_ENABLE_TARGET_MODE; 2395 mbs.param[1] = (ena)? ENABLE_TARGET_FLAG : 0; 2396 isp_mboxcmd(isp, &mbs, MBLOGALL); 2397 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { 2398 break; 2399 } |
2400 } else { 2401 fcparam *fcp = isp->isp_param; 2402 /* 2403 * We assume somebody has quiesced this bus. 2404 */ 2405 if (ena) { 2406 if (fcp->isp_fwoptions & ICBOPT_TGT_ENABLE) { 2407 return (0); 2408 } 2409 fcp->isp_fwoptions |= ICBOPT_TGT_ENABLE; 2410 } else { 2411 if (!(fcp->isp_fwoptions & ICBOPT_TGT_ENABLE)) { 2412 return (0); 2413 } 2414 fcp->isp_fwoptions &= ~ICBOPT_TGT_ENABLE; 2415 } 2416 isp->isp_state = ISP_NILSTATE; 2417 isp_reset(isp); 2418 if (isp->isp_state != ISP_RESETSTATE) { 2419 break; 2420 } 2421 isp_init(isp); 2422 if (isp->isp_state != ISP_INITSTATE) { 2423 break; 2424 } 2425 isp->isp_state = ISP_RUNSTATE; |
2426 } 2427 return (0); |
2428 } |
2429#endif 2430 } 2431 return (-1); 2432} 2433 2434/* 2435 * Interrupt Service Routine(s). 2436 * --- 162 unchanged lines hidden (view full) --- 2599 /* 2600 * Do any appropriate unswizzling of what the Qlogic f/w has 2601 * written into memory so it makes sense to us. This is a 2602 * per-platform thing. Also includes any memory barriers. 2603 */ 2604 ISP_UNSWIZZLE_RESPONSE(isp, sp, oop); 2605 if (sp->req_header.rqs_entry_type != RQSTYPE_RESPONSE) { 2606 if (isp_handle_other_response(isp, sp, &optr) == 0) { |
2607 MEMZERO(sp, sizeof (isphdr_t)); |
2608 continue; 2609 } 2610 /* 2611 * It really has to be a bounced request just copied 2612 * from the request queue to the response queue. If 2613 * not, something bad has happened. 2614 */ 2615 if (sp->req_header.rqs_entry_type != RQSTYPE_REQUEST) { 2616 isp_prt(isp, ISP_LOGERR, notresp, 2617 sp->req_header.rqs_entry_type, oop, optr); |
2618 MEMZERO(sp, sizeof (isphdr_t)); |
2619 continue; 2620 } 2621 buddaboom = 1; 2622 } 2623 2624 if (sp->req_header.rqs_flags & 0xf) { 2625#define _RQS_OFLAGS \ 2626 ~(RQSFLAG_CONTINUATION|RQSFLAG_FULL|RQSFLAG_BADHEADER|RQSFLAG_BADPACKET) --- 22 unchanged lines hidden (view full) --- 2649 isp_prt(isp, ISP_LOGERR, 2650 "unknown flags (0x%x) in response", 2651 sp->req_header.rqs_flags); 2652 buddaboom++; 2653 } 2654#undef _RQS_OFLAGS 2655 } 2656 if (sp->req_handle > isp->isp_maxcmds || sp->req_handle < 1) { |
2657 MEMZERO(sp, sizeof (isphdr_t)); |
2658 isp_prt(isp, ISP_LOGERR, 2659 "bad request handle %d", sp->req_handle); 2660 ISP_WRITE(isp, INMAILBOX5, optr); 2661 continue; 2662 } 2663 xs = isp_find_xs(isp, sp->req_handle); 2664 if (xs == NULL) { |
2665 MEMZERO(sp, sizeof (isphdr_t)); |
2666 isp_prt(isp, ISP_LOGERR, 2667 "cannot find handle 0x%x in xflist", 2668 sp->req_handle); 2669 ISP_WRITE(isp, INMAILBOX5, optr); 2670 continue; 2671 } 2672 isp_destroy_handle(isp, sp->req_handle); 2673 if (sp->req_status_flags & RQSTF_BUS_RESET) { 2674 isp->isp_sendmarker |= (1 << XS_CHANNEL(xs)); 2675 } 2676 if (buddaboom) { 2677 XS_SETERR(xs, HBA_BOTCH); 2678 } |
2679 2680 if (IS_FC(isp) && (sp->req_scsi_status & RQCS_SV)) { |
2681 /* |
2682 * Fibre Channel F/W doesn't say we got status 2683 * if there's Sense Data instead. I guess they 2684 * think it goes w/o saying. |
2685 */ |
2686 sp->req_state_flags |= RQSF_GOT_STATUS; |
2687 } |
2688 if (sp->req_state_flags & RQSF_GOT_STATUS) { 2689 *XS_STSP(xs) = sp->req_scsi_status & 0xff; 2690 } |
2691 |
2692 switch (sp->req_header.rqs_entry_type) { 2693 case RQSTYPE_RESPONSE: |
2694 XS_SET_STATE_STAT(isp, xs, sp); 2695 isp_parse_status(isp, sp, xs); 2696 if ((XS_NOERR(xs) || XS_ERR(xs) == HBA_NOERROR) && 2697 (*XS_STSP(xs) == SCSI_BUSY)) { 2698 XS_SETERR(xs, HBA_TGTBSY); 2699 } |
2700 if (IS_SCSI(isp)) { 2701 XS_RESID(xs) = sp->req_resid; 2702 if ((sp->req_state_flags & RQSF_GOT_STATUS) && 2703 (*XS_STSP(xs) == SCSI_CHECK) && 2704 (sp->req_state_flags & RQSF_GOT_SENSE)) { 2705 XS_SAVE_SENSE(xs, sp); 2706 } 2707 /* 2708 * A new synchronous rate was negotiated for 2709 * this target. Mark state such that we'll go 2710 * look up that which has changed later. 2711 */ 2712 if (sp->req_status_flags & RQSTF_NEGOTIATION) { 2713 int t = XS_TGT(xs); 2714 sdparam *sdp = isp->isp_param; 2715 sdp += XS_CHANNEL(xs); 2716 sdp->isp_devparam[t].dev_refresh = 1; 2717 isp->isp_update |= 2718 (1 << XS_CHANNEL(xs)); 2719 } 2720 } else { 2721 if (sp->req_status_flags & RQSF_XFER_COMPLETE) { 2722 XS_RESID(xs) = 0; 2723 } else if (sp->req_scsi_status & RQCS_RESID) { 2724 XS_RESID(xs) = sp->req_resid; 2725 } else { 2726 XS_RESID(xs) = 0; 2727 } 2728 if ((sp->req_state_flags & RQSF_GOT_STATUS) && 2729 (*XS_STSP(xs) == SCSI_CHECK) && 2730 (sp->req_scsi_status & RQCS_SV)) { 2731 XS_SAVE_SENSE(xs, sp); 2732 } 2733 } 2734 isp_prt(isp, ISP_LOGDEBUG2, "asked for %d got resid %d", 2735 XS_XFRLEN(xs), sp->req_resid); 2736 break; 2737 case RQSTYPE_REQUEST: |
2738 if (sp->req_header.rqs_flags & RQSFLAG_FULL) { 2739 /* 2740 * Force Queue Full status. 2741 */ 2742 *XS_STSP(xs) = SCSI_QFULL; 2743 XS_SETERR(xs, HBA_NOERROR); 2744 } else if (XS_NOERR(xs)) { 2745 XS_SETERR(xs, HBA_BOTCH); 2746 } |
2747 XS_RESID(xs) = XS_XFRLEN(xs); 2748 break; 2749 default: |
2750 isp_prt(isp, ISP_LOGWARN, 2751 "unhandled respose queue type 0x%x", 2752 sp->req_header.rqs_entry_type); 2753 if (XS_NOERR(xs)) { 2754 XS_SETERR(xs, HBA_BOTCH); 2755 } |
2756 break; |
2757 } |
2758 2759 /* 2760 * Free any dma resources. As a side effect, this may 2761 * also do any cache flushing necessary for data coherence. */ |
2762 if (XS_XFRLEN(xs)) { 2763 ISP_DMAFREE(isp, xs, sp->req_handle); 2764 } |
2765 |
2766 if (((isp->isp_dblev & (ISP_LOGDEBUG2|ISP_LOGDEBUG3))) || 2767 ((isp->isp_dblev & ISP_LOGDEBUG1) && !XS_NOERR(xs))) { 2768 char skey; 2769 if (sp->req_state_flags & RQSF_GOT_SENSE) { 2770 skey = XS_SNSKEY(xs) & 0xf; 2771 if (skey < 10) 2772 skey += '0'; 2773 else --- 6 unchanged lines hidden (view full) --- 2780 isp_prt(isp, ISP_LOGALL, finmsg, XS_CHANNEL(xs), 2781 XS_TGT(xs), XS_LUN(xs), XS_XFRLEN(xs), XS_RESID(xs), 2782 *XS_STSP(xs), skey, XS_ERR(xs)); 2783 } 2784 2785 if (isp->isp_nactive > 0) 2786 isp->isp_nactive--; 2787 complist[ndone++] = xs; /* defer completion call until later */ |
2788 MEMZERO(sp, sizeof (isphdr_t)); |
2789 if (ndone == MAX_REQUESTQ_COMPLETIONS) { 2790 break; 2791 } 2792 } 2793 2794 /* 2795 * If we looked at any commands, then it's valid to find out 2796 * what the outpointer is. It also is a trigger to update the --- 28 unchanged lines hidden (view full) --- 2825 2826 if (IS_DUALBUS(isp)) { 2827 bus = ISP_READ(isp, OUTMAILBOX6); 2828 } else { 2829 bus = 0; 2830 } 2831 2832 switch (mbox) { |
2833 case ASYNC_BUS_RESET: 2834 isp->isp_sendmarker |= (1 << bus); 2835#ifdef ISP_TARGET_MODE 2836 isp_target_async(isp, bus, mbox); 2837#endif 2838 isp_async(isp, ISPASYNC_BUS_RESET, &bus); 2839 break; 2840 case ASYNC_SYSTEM_ERROR: --- 56 unchanged lines hidden (view full) --- 2897 isp_prt(isp, ISP_LOGERR, "SCSI Bus reset after DATA Overrun"); 2898 break; 2899 2900 case ASYNC_BUS_TRANSIT: 2901 mbox = ISP_READ(isp, OUTMAILBOX2); 2902 switch (mbox & 0x1c00) { 2903 case SXP_PINS_LVD_MODE: 2904 isp_prt(isp, ISP_LOGINFO, "Transition to LVD mode"); |
2905 SDPARAM(isp)->isp_diffmode = 0; 2906 SDPARAM(isp)->isp_ultramode = 0; 2907 SDPARAM(isp)->isp_lvdmode = 1; |
2908 break; 2909 case SXP_PINS_HVD_MODE: 2910 isp_prt(isp, ISP_LOGINFO, 2911 "Transition to Differential mode"); |
2912 SDPARAM(isp)->isp_diffmode = 1; 2913 SDPARAM(isp)->isp_ultramode = 0; 2914 SDPARAM(isp)->isp_lvdmode = 0; |
2915 break; 2916 case SXP_PINS_SE_MODE: 2917 isp_prt(isp, ISP_LOGINFO, 2918 "Transition to Single Ended mode"); |
2919 SDPARAM(isp)->isp_diffmode = 0; 2920 SDPARAM(isp)->isp_ultramode = 1; 2921 SDPARAM(isp)->isp_lvdmode = 0; |
2922 break; 2923 default: 2924 isp_prt(isp, ISP_LOGWARN, 2925 "Transition to Unknown Mode 0x%x", mbox); 2926 break; 2927 } 2928 /* 2929 * XXX: Set up to renegotiate again! --- 5 unchanged lines hidden (view full) --- 2935 case ASYNC_CMD_CMPLT: 2936 fast_post_handle = (ISP_READ(isp, OUTMAILBOX2) << 16) | 2937 ISP_READ(isp, OUTMAILBOX1); 2938 isp_prt(isp, ISP_LOGDEBUG3, "fast post completion of %u", 2939 fast_post_handle); 2940 break; 2941 2942 case ASYNC_CTIO_DONE: |
2943#ifdef ISP_TARGET_MODE 2944 /* 2945 * Bus gets overloaded with the handle. Dual bus 2946 * cards don't put bus# into the handle. 2947 */ 2948 bus = (ISP_READ(isp, OUTMAILBOX2) << 16) | 2949 ISP_READ(isp, OUTMAILBOX1); 2950 isp_target_async(isp, bus, mbox); 2951#else 2952 isp_prt(isp, ISP_LOGINFO, "Fast Posting CTIO done"); 2953#endif |
2954 break; 2955 2956 case ASYNC_LIP_OCCURRED: |
2957 FCPARAM(isp)->isp_lipseq = |
2958 ISP_READ(isp, OUTMAILBOX1); |
2959 FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT; 2960 FCPARAM(isp)->isp_loopstate = LOOP_LIP_RCVD; |
2961 isp->isp_sendmarker = 1; 2962 isp_mark_getpdb_all(isp); 2963 isp_prt(isp, ISP_LOGINFO, "LIP occurred"); 2964#ifdef ISP_TARGET_MODE 2965 isp_target_async(isp, bus, mbox); 2966#endif 2967 break; 2968 2969 case ASYNC_LOOP_UP: 2970 isp->isp_sendmarker = 1; |
2971 FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT; 2972 FCPARAM(isp)->isp_loopstate = LOOP_LIP_RCVD; |
2973 isp_mark_getpdb_all(isp); 2974 isp_async(isp, ISPASYNC_LOOP_UP, NULL); 2975#ifdef ISP_TARGET_MODE 2976 isp_target_async(isp, bus, mbox); 2977#endif 2978 break; 2979 2980 case ASYNC_LOOP_DOWN: 2981 isp->isp_sendmarker = 1; |
2982 FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT; 2983 FCPARAM(isp)->isp_loopstate = LOOP_NIL; |
2984 isp_mark_getpdb_all(isp); 2985 isp_async(isp, ISPASYNC_LOOP_DOWN, NULL); 2986#ifdef ISP_TARGET_MODE 2987 isp_target_async(isp, bus, mbox); 2988#endif 2989 break; 2990 2991 case ASYNC_LOOP_RESET: 2992 isp->isp_sendmarker = 1; |
2993 FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT; 2994 FCPARAM(isp)->isp_loopstate = LOOP_NIL; |
2995 isp_mark_getpdb_all(isp); 2996 isp_prt(isp, ISP_LOGINFO, "Loop RESET"); 2997#ifdef ISP_TARGET_MODE 2998 isp_target_async(isp, bus, mbox); 2999#endif 3000 break; 3001 3002 case ASYNC_PDB_CHANGED: 3003 isp->isp_sendmarker = 1; |
3004 FCPARAM(isp)->isp_loopstate = LOOP_PDB_RCVD; |
3005 isp_mark_getpdb_all(isp); 3006 isp_prt(isp, ISP_LOGINFO, "Port Database Changed"); 3007 break; 3008 3009 case ASYNC_CHANGE_NOTIFY: 3010 isp_mark_getpdb_all(isp); 3011 /* 3012 * Not correct, but it will force us to rescan the loop. 3013 */ |
3014 FCPARAM(isp)->isp_loopstate = LOOP_PDB_RCVD; |
3015 isp_async(isp, ISPASYNC_CHANGE_NOTIFY, NULL); 3016 break; 3017 3018 case ASYNC_PTPMODE: |
3019 if (FCPARAM(isp)->isp_onfabric) 3020 FCPARAM(isp)->isp_topo = TOPO_N_PORT; |
3021 else |
3022 FCPARAM(isp)->isp_topo = TOPO_F_PORT; |
3023 isp_mark_getpdb_all(isp); 3024 isp->isp_sendmarker = 1; |
3025 FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT; 3026 FCPARAM(isp)->isp_loopstate = LOOP_LIP_RCVD; |
3027#ifdef ISP_TARGET_MODE 3028 isp_target_async(isp, bus, mbox); 3029#endif 3030 isp_prt(isp, ISP_LOGINFO, "Point-to-Point mode"); 3031 break; 3032 3033 case ASYNC_CONNMODE: 3034 mbox = ISP_READ(isp, OUTMAILBOX1); --- 35 unchanged lines hidden (view full) --- 3070 3071static int 3072isp_handle_other_response(isp, sp, optrp) 3073 struct ispsoftc *isp; 3074 ispstatusreq_t *sp; 3075 u_int16_t *optrp; 3076{ 3077 switch (sp->req_header.rqs_entry_type) { |
3078 case RQSTYPE_STATUS_CONT: 3079 isp_prt(isp, ISP_LOGINFO, "Ignored Continuation Response"); 3080 return (0); |
3081 case RQSTYPE_ATIO: 3082 case RQSTYPE_CTIO: 3083 case RQSTYPE_ENABLE_LUN: 3084 case RQSTYPE_MODIFY_LUN: 3085 case RQSTYPE_NOTIFY: 3086 case RQSTYPE_NOTIFY_ACK: 3087 case RQSTYPE_CTIO1: 3088 case RQSTYPE_ATIO2: --- 23 unchanged lines hidden (view full) --- 3112 case RQCS_COMPLETE: 3113 if (XS_NOERR(xs)) { 3114 XS_SETERR(xs, HBA_NOERROR); 3115 } 3116 return; 3117 3118 case RQCS_INCOMPLETE: 3119 if ((sp->req_state_flags & RQSF_GOT_TARGET) == 0) { |
3120 isp_prt(isp, ISP_LOGDEBUG1, |
3121 "Selection Timeout for %d.%d.%d", 3122 XS_TGT(xs), XS_LUN(xs), XS_CHANNEL(xs)); 3123 if (XS_NOERR(xs)) { 3124 XS_SETERR(xs, HBA_SELTIMEOUT); 3125 } 3126 return; 3127 } 3128 isp_prt(isp, ISP_LOGERR, --- 86 unchanged lines hidden (view full) --- 3215 isp_prt(isp, ISP_LOGWARN, "command timed out for %d.%d.%d", 3216 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs)); 3217 if (XS_NOERR(xs)) { 3218 XS_SETERR(xs, HBA_CMDTIMEOUT); 3219 } 3220 return; 3221 3222 case RQCS_DATA_OVERRUN: |
3223 XS_RESID(xs) = sp->req_resid; |
3224 isp_prt(isp, ISP_LOGERR, "data overrun for command on %d.%d.%d", 3225 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs)); 3226 if (XS_NOERR(xs)) { 3227 XS_SETERR(xs, HBA_DATAOVR); 3228 } 3229 return; 3230 3231 case RQCS_COMMAND_OVERRUN: --- 64 unchanged lines hidden (view full) --- 3296 break; 3297 3298 case RQCS_UNEXP_BUS_FREE: 3299 isp_prt(isp, ISP_LOGERR, "%d.%d.%d had an unexpected bus free", 3300 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs)); 3301 break; 3302 3303 case RQCS_DATA_UNDERRUN: |
3304 XS_RESID(xs) = sp->req_resid; |
3305 if (XS_NOERR(xs)) { 3306 XS_SETERR(xs, HBA_NOERROR); 3307 } 3308 return; 3309 3310 case RQCS_XACT_ERR1: 3311 isp_prt(isp, ISP_LOGERR, xact1, XS_CHANNEL(xs), 3312 XS_TGT(xs), XS_LUN(xs)); --- 148 unchanged lines hidden (view full) --- 3461 * that all data transferred. 3462 */ 3463 XS_SET_STATE_STAT(isp, xs, NULL); 3464 XS_RESID(xs) = 0; 3465 *XS_STSP(xs) = SCSI_GOOD; 3466 if (XS_XFRLEN(xs)) { 3467 ISP_DMAFREE(isp, xs, fph); 3468 } |
3469 if (isp->isp_nactive) 3470 isp->isp_nactive--; |
3471 isp_done(xs); |
3472} 3473 3474#define HIBYT(x) ((x) >> 0x8) 3475#define LOBYT(x) ((x) & 0xff) 3476#define ISPOPMAP(a, b) (((a) << 8) | (b)) 3477static u_int16_t mbpscsi[] = { 3478 ISPOPMAP(0x01, 0x01), /* 0x00: MBOX_NO_OP */ 3479 ISPOPMAP(0x1f, 0x01), /* 0x01: MBOX_LOAD_RAM */ --- 607 unchanged lines hidden (view full) --- 4087 fcp->isp_fwstate = mbs.param[1]; 4088 } 4089} 4090 4091static void 4092isp_update(isp) 4093 struct ispsoftc *isp; 4094{ |
4095 int bus, upmask; |
4096 |
4097 for (bus = 0, upmask = isp->isp_update; upmask != 0; bus++) { 4098 if (upmask & (1 << bus)) { |
4099 isp_update_bus(isp, bus); |
4100 } |
4101 upmask &= ~(1 << bus); |
4102 } 4103} 4104 4105static void 4106isp_update_bus(isp, bus) 4107 struct ispsoftc *isp; 4108 int bus; 4109{ 4110 int tgt; 4111 mbreg_t mbs; 4112 sdparam *sdp; 4113 |
4114 isp->isp_update &= ~(1 << bus); |
4115 if (IS_FC(isp)) { |
4116 /* 4117 * There are no 'per-bus' settings for Fibre Channel. 4118 */ |
4119 return; 4120 } |
4121 sdp = isp->isp_param; 4122 sdp += bus; 4123 4124 for (tgt = 0; tgt < MAX_TARGETS; tgt++) { 4125 u_int16_t flags, period, offset; 4126 int get; 4127 4128 if (sdp->isp_devparam[tgt].dev_enable == 0) { |
4129 sdp->isp_devparam[tgt].dev_update = 0; 4130 sdp->isp_devparam[tgt].dev_refresh = 0; |
4131 isp_prt(isp, ISP_LOGDEBUG1, 4132 "skipping target %d bus %d update", tgt, bus); 4133 continue; 4134 } |
4135 /* 4136 * If the goal is to update the status of the device, 4137 * take what's in dev_flags and try and set the device 4138 * toward that. Otherwise, if we're just refreshing the 4139 * current device state, get the current parameters. 4140 */ |
4141 4142 /* 4143 * Refresh overrides set 4144 */ 4145 if (sdp->isp_devparam[tgt].dev_refresh) { 4146 mbs.param[0] = MBOX_GET_TARGET_PARAMS; 4147 sdp->isp_devparam[tgt].dev_refresh = 0; 4148 get = 1; 4149 } else if (sdp->isp_devparam[tgt].dev_update) { |
4150 mbs.param[0] = MBOX_SET_TARGET_PARAMS; |
4151 /* 4152 * Make sure dev_flags has "Renegotiate on Error" 4153 * on and "Freeze Queue on Error" off. 4154 */ 4155 sdp->isp_devparam[tgt].dev_flags |= DPARM_RENEG; 4156 sdp->isp_devparam[tgt].dev_flags &= ~DPARM_QFRZ; 4157 |
4158 mbs.param[2] = sdp->isp_devparam[tgt].dev_flags; |
4159 |
4160 /* |
4161 * Insist that PARITY must be enabled 4162 * if SYNC or WIDE is enabled. |
4163 */ |
4164 if ((mbs.param[2] & (DPARM_SYNC|DPARM_WIDE)) != 0) { |
4165 mbs.param[2] |= DPARM_PARITY; 4166 } |
4167 4168 if ((mbs.param[2] & DPARM_SYNC) == 0) { 4169 mbs.param[3] = 0; 4170 } else { 4171 mbs.param[3] = 4172 (sdp->isp_devparam[tgt].sync_offset << 8) | 4173 (sdp->isp_devparam[tgt].sync_period); 4174 } |
4175 /* 4176 * A command completion later that has |
4177 * RQSTF_NEGOTIATION set canl cause 4178 * the dev_refresh/announce cycle also. 4179 & |
4180 * 4181 * Note: It is really important to update our current 4182 * flags with at least the state of TAG capabilities- 4183 * otherwise we might try and send a tagged command 4184 * when we have it all turned off. So change it here 4185 * to say that current already matches goal. 4186 */ 4187 sdp->isp_devparam[tgt].cur_dflags &= ~DPARM_TQING; 4188 sdp->isp_devparam[tgt].cur_dflags |= 4189 (sdp->isp_devparam[tgt].dev_flags & DPARM_TQING); |
4190 isp_prt(isp, ISP_LOGDEBUG2, 4191 "bus %d set tgt %d flags 0x%x off 0x%x period 0x%x", 4192 bus, tgt, mbs.param[2], mbs.param[3] >> 8, 4193 mbs.param[3] & 0xff); |
4194 sdp->isp_devparam[tgt].dev_update = 0; 4195 sdp->isp_devparam[tgt].dev_refresh = 1; |
4196 get = 0; |
4197 } else { 4198 continue; 4199 } 4200 mbs.param[1] = (bus << 15) | (tgt << 8) ; 4201 isp_mboxcmd(isp, &mbs, MBLOGALL); 4202 if (get == 0) { 4203 isp->isp_sendmarker |= (1 << bus); 4204 continue; 4205 } 4206 flags = mbs.param[2]; 4207 period = mbs.param[3] & 0xff; 4208 offset = mbs.param[3] >> 8; 4209 sdp->isp_devparam[tgt].cur_dflags = flags; 4210 sdp->isp_devparam[tgt].cur_period = period; 4211 sdp->isp_devparam[tgt].cur_offset = offset; 4212 get = (bus << 16) | tgt; 4213 (void) isp_async(isp, ISPASYNC_NEW_TGT_PARAMS, &get); 4214 } |
4215 4216 for (tgt = 0; tgt < MAX_TARGETS; tgt++) { 4217 if (sdp->isp_devparam[tgt].dev_update || 4218 sdp->isp_devparam[tgt].dev_refresh) { 4219 isp->isp_update |= (1 << bus); 4220 break; 4221 } 4222 } |
4223} 4224 4225static void 4226isp_setdfltparm(isp, channel) 4227 struct ispsoftc *isp; 4228 int channel; 4229{ 4230 int tgt; --- 4 unchanged lines hidden (view full) --- 4235 fcparam *fcp = (fcparam *) isp->isp_param; 4236 fcp += channel; 4237 if (fcp->isp_gotdparms) { 4238 return; 4239 } 4240 fcp->isp_gotdparms = 1; 4241 fcp->isp_maxfrmlen = ICB_DFLT_FRMLEN; 4242 fcp->isp_maxalloc = ICB_DFLT_ALLOC; |
4243 fcp->isp_execthrottle = ISP_EXEC_THROTTLE; |
4244 fcp->isp_retry_delay = ICB_DFLT_RDELAY; 4245 fcp->isp_retry_count = ICB_DFLT_RCOUNT; 4246 /* Platform specific.... */ 4247 fcp->isp_loopid = DEFAULT_LOOPID(isp); 4248 fcp->isp_nodewwn = DEFAULT_NODEWWN(isp); 4249 fcp->isp_portwwn = DEFAULT_PORTWWN(isp); |
4250 fcp->isp_fwoptions = 0; 4251 fcp->isp_fwoptions |= ICBOPT_FAIRNESS; 4252 fcp->isp_fwoptions |= ICBOPT_PDBCHANGE_AE; 4253 fcp->isp_fwoptions |= ICBOPT_HARD_ADDRESS; 4254#ifndef ISP_NO_FASTPOST_FC 4255 fcp->isp_fwoptions |= ICBOPT_FAST_POST; 4256#endif 4257 if (isp->isp_confopts & ISP_CFG_FULL_DUPLEX) 4258 fcp->isp_fwoptions |= ICBOPT_FULL_DUPLEX; |
4259 4260 /* |
4261 * Make sure this is turned off now until we get 4262 * extended options from NVRAM 4263 */ 4264 fcp->isp_fwoptions &= ~ICBOPT_EXTENDED; 4265 4266 /* |
4267 * Now try and read NVRAM 4268 */ 4269 if ((isp->isp_confopts & (ISP_CFG_NONVRAM|ISP_CFG_OWNWWN)) || 4270 (isp_read_nvram(isp))) { 4271 isp_prt(isp, ISP_LOGINFO, 4272 "Node WWN 0x%08x%08x, Port WWN 0x%08x%08x", 4273 (u_int32_t) (fcp->isp_nodewwn >> 32), 4274 (u_int32_t) (fcp->isp_nodewwn & 0xffffffff), --- 73 unchanged lines hidden (view full) --- 4348 (isp->isp_bustype == ISP_BT_PCI && 4349 isp->isp_type < ISP_HA_SCSI_1040) || 4350 (isp->isp_clock && isp->isp_clock < 60) || 4351 (sdp->isp_ultramode == 0)) { 4352 sdp->isp_devparam[tgt].sync_offset = 4353 ISP_10M_SYNCPARMS >> 8; 4354 sdp->isp_devparam[tgt].sync_period = 4355 ISP_10M_SYNCPARMS & 0xff; |
4356 } else if (IS_ULTRA3(isp)) { 4357 sdp->isp_devparam[tgt].sync_offset = 4358 ISP_80M_SYNCPARMS >> 8; 4359 sdp->isp_devparam[tgt].sync_period = 4360 ISP_80M_SYNCPARMS & 0xff; |
4361 } else if (IS_ULTRA2(isp)) { 4362 sdp->isp_devparam[tgt].sync_offset = 4363 ISP_40M_SYNCPARMS >> 8; 4364 sdp->isp_devparam[tgt].sync_period = 4365 ISP_40M_SYNCPARMS & 0xff; |
4366 } else if (IS_1240(isp)) { |
4367 sdp->isp_devparam[tgt].sync_offset = 4368 ISP_20M_SYNCPARMS >> 8; 4369 sdp->isp_devparam[tgt].sync_period = 4370 ISP_20M_SYNCPARMS & 0xff; |
4371 } else { 4372 sdp->isp_devparam[tgt].sync_offset = 4373 ISP_20M_SYNCPARMS_1040 >> 8; 4374 sdp->isp_devparam[tgt].sync_period = 4375 ISP_20M_SYNCPARMS_1040 & 0xff; |
4376 } 4377 4378 /* 4379 * Don't get current target parameters if we've been 4380 * told not to use NVRAM- it's really the same thing. 4381 */ 4382 if ((isp->isp_confopts & ISP_CFG_NONVRAM) == 0) { 4383 --- 31 unchanged lines hidden (view full) --- 4415 (ISP_20M_SYNCPARMS & 0xff))) { 4416 sdp->isp_devparam[tgt].sync_offset = 4417 ISP_10M_SYNCPARMS >> 8; 4418 sdp->isp_devparam[tgt].sync_period = 4419 ISP_10M_SYNCPARMS & 0xff; 4420 } 4421 } 4422 isp_prt(isp, ISP_LOGDEBUG1, |
4423 "Initial bus %d tgt %d flags %x offset %x period %x", |
4424 channel, tgt, sdp->isp_devparam[tgt].dev_flags, 4425 sdp->isp_devparam[tgt].sync_offset, 4426 sdp->isp_devparam[tgt].sync_period); 4427 } 4428 4429 /* 4430 * Establish default some more default parameters. 4431 */ --- 9 unchanged lines hidden (view full) --- 4441 sdp->isp_selection_timeout = 250; 4442 sdp->isp_max_queue_depth = MAXISPREQUEST(isp); 4443 sdp->isp_tag_aging = 8; 4444 sdp->isp_bus_reset_delay = 3; 4445 sdp->isp_retry_count = 2; 4446 sdp->isp_retry_delay = 2; 4447 4448 for (tgt = 0; tgt < MAX_TARGETS; tgt++) { |
4449 sdp->isp_devparam[tgt].exc_throttle = ISP_EXEC_THROTTLE; |
4450 sdp->isp_devparam[tgt].dev_enable = 1; 4451 } 4452} 4453 4454/* 4455 * Re-initialize the ISP and complete all orphaned commands 4456 * with a 'botched' notice. The reset/init routines should 4457 * not disturb an already active list of commands. --- 233 unchanged lines hidden (view full) --- 4691 ISP_NVRAM_TAG_AGE_LIMIT(nvram_data); 4692 4693 sdp->isp_selection_timeout = 4694 ISP_NVRAM_SELECTION_TIMEOUT(nvram_data); 4695 4696 sdp->isp_max_queue_depth = 4697 ISP_NVRAM_MAX_QUEUE_DEPTH(nvram_data); 4698 |
4699 sdp->isp_fast_mttr = ISP_NVRAM_FAST_MTTR_ENABLE(nvram_data); |
4700 for (i = 0; i < MAX_TARGETS; i++) { 4701 sdp->isp_devparam[i].dev_enable = 4702 ISP_NVRAM_TGT_DEVICE_ENABLE(nvram_data, i); 4703 sdp->isp_devparam[i].exc_throttle = 4704 ISP_NVRAM_TGT_EXEC_THROTTLE(nvram_data, i); 4705 sdp->isp_devparam[i].sync_offset = 4706 ISP_NVRAM_TGT_SYNC_OFFSET(nvram_data, i); 4707 sdp->isp_devparam[i].sync_period = --- 242 unchanged lines hidden --- |