From owner-svn-src-all@freebsd.org Mon Nov 30 21:55:37 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4E132A3DC93; Mon, 30 Nov 2015 21:55:37 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1AF6213A9; Mon, 30 Nov 2015 21:55:37 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id tAULtaDA077248; Mon, 30 Nov 2015 21:55:36 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tAULtaC2077244; Mon, 30 Nov 2015 21:55:36 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201511302155.tAULtaC2077244@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Mon, 30 Nov 2015 21:55:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r291528 - in stable/10: share/man/man4 sys/dev/isp sys/dev/ispfw sys/modules/ispfw sys/modules/ispfw/isp_1040_it sys/modules/ispfw/isp_1080_it sys/modules/ispfw/isp_12160_it X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Nov 2015 21:55:37 -0000 Author: mav Date: Mon Nov 30 21:55:35 2015 New Revision: 291528 URL: https://svnweb.freebsd.org/changeset/base/291528 Log: MFC r291188: Rip off target mode support for parallel SCSI QLogic adapters. Hacks to enable target mode there complicated code, while didn't really work. And for outdated hardware fixing it is not really interesting. Initiator mode tested with Qlogic 1080 adapter is still working fine. Deleted: stable/10/sys/modules/ispfw/isp_1040_it/ stable/10/sys/modules/ispfw/isp_1080_it/ stable/10/sys/modules/ispfw/isp_12160_it/ Modified: stable/10/share/man/man4/isp.4 stable/10/sys/dev/isp/isp.c stable/10/sys/dev/isp/isp_freebsd.c stable/10/sys/dev/isp/isp_freebsd.h stable/10/sys/dev/isp/isp_library.c stable/10/sys/dev/isp/isp_library.h stable/10/sys/dev/isp/isp_pci.c stable/10/sys/dev/isp/isp_sbus.c stable/10/sys/dev/isp/isp_target.c stable/10/sys/dev/isp/ispvar.h stable/10/sys/dev/ispfw/asm_1040.h stable/10/sys/dev/ispfw/asm_1080.h stable/10/sys/dev/ispfw/asm_12160.h stable/10/sys/dev/ispfw/ispfw.c stable/10/sys/modules/ispfw/Makefile Directory Properties: stable/10/ (props changed) Modified: stable/10/share/man/man4/isp.4 ============================================================================== --- stable/10/share/man/man4/isp.4 Mon Nov 30 21:54:27 2015 (r291527) +++ stable/10/share/man/man4/isp.4 Mon Nov 30 21:55:35 2015 (r291528) @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 29, 2015 +.Dd November 22, 2015 .Dt ISP 4 .Os .Sh NAME @@ -60,31 +60,20 @@ devices. SCSI features include support for Ultra SCSI and wide mode transactions for .Tn SCSI , -Ultra2 LVD (ISP1080, ISP1280), and Ultra3 LVD (ISP12160). +Ultra2 LVD (1080, 1280), and Ultra3 LVD (10160, 12160). .Pp Fibre Channel support uses FCP SCSI profile for .Tn FibreChannel , -and utilizes Class 3 and Class 2 connections (Qlogic 2100 is Class -3 only, minor patches to the Qlogic 2200 to force Class 2 mode). -Support is available for Public and Private loops, and for -point-to-point connections (Qlogic 2200 only). +and utilizes Class 3 and Class 2 (2200 and later) connections. +Support is available for Public and Private loops, Point-to-Point +and Fabric connections. The newer 2-Gigabit cards (2300, 2312, 2322), 4-Gigabit (2422, 2432) -and 8-Gigabit (2532) are also supported. -Command tagging is supported for all (in fact, -.Tn FibreChannel -requires tagging). -Fabric support is enabled by default for other than 2100 cards. -Fabric support for 2100 cards has been so problematic and these cards are so -old now that it is just not worth your time to try it. +and 8-Gigabit (2532) are supported in both initiator and target modes. .Sh FIRMWARE -Firmware is available if the +Firmware loading is supported if the .Xr ispfw 4 -module is loaded during bootstrap (q.v.). -.Pp -It is -.Ar strongly -recommended that you use the firmware available -from +module is loaded. +It is strongly recommended that you use the firmware available from .Xr ispfw 4 as it is the most likely to have been tested with this driver. .Sh HARDWARE @@ -92,53 +81,47 @@ Cards supported by the .Nm driver include: .Bl -tag -width xxxxxx -offset indent -.It ISP1000 -SBus Fast Wide, Ultra Fast Wide cards, Single Ended or Differential -cards. -.It ISP1020 -Qlogic 1020 Fast Wide and Differential Fast Wide PCI cards. -.It ISP1040 -Qlogic 1040 Ultra Wide and Differential Ultra Wide PCI cards. -Also known as the DEC KZPBA-CA (single ended) and KZPBA-CB (HVD differential). +.It Qlogic 1000 +Fast Wide, Ultra Fast Wide cards, Single Ended or Differential SBus cards. .It Qlogic 1020 -Qlogic 1020 SCSI cards. +Fast Wide and Differential Fast Wide SCSI PCI cards. .It Qlogic 1040 -Qlogic 1040 Ultra SCSI cards. +Ultra Wide and Differential Ultra Wide SCSI PCI cards. +Also known as the DEC KZPBA-CA (single ended) and KZPBA-CB (HVD differential). .It Qlogic 1080 -Qlogic 1080 LVD Ultra2 Wide SCSI cards. +LVD Ultra2 Wide SCSI PCI cards. .It Qlogic 10160 -Qlogic 10160 LVD Ultra3 Wide PCI cards. +LVD Ultra3 Wide SCSI PCI cards. .It Qlogic 1240 -Qlogic 1240 Dual Bus Ultra Wide and Differential Ultra Wide PCI cards. +Dual Bus Ultra Wide and Differential Ultra Wide SCSI PCI cards. .It Qlogic 1280 -Qlogic 1280 Dual Bus LVD Ultra2 Wide PCI cards. +Dual Bus LVD Ultra2 Wide SCSI PCI cards. .It Qlogic 12160 -Qlogic 12160 Dual Bus LVD Ultra3 Wide PCI cards. +Dual Bus LVD Ultra3 Wide SCSI PCI cards. .It Qlogic 210X -Qlogic 2100 and 2100A Copper and Optical Fibre Channel Arbitrated -Loop (single, dual). +Copper and Optical Fibre Channel Arbitrated Loop PCI cards (single, dual). .It Qlogic 220X -Qlogic 2200 Copper and Optical Fibre Channel Arbitrated Loop PCI -cards (single, dual, quad). +Copper and Optical Fibre Channel Arbitrated Loop PCI cards (single, dual, quad). .It Qlogic 2300 -Qlogic 2300 Optical 2Gb Fibre Channel PCI cards. +Optical 2Gb Fibre Channel PCI cards. .It Qlogic 2312 -Qlogic 2312 Optical 2Gb Fibre Channel PCI cards. +Optical 2Gb Fibre Channel PCI cards. .It Qlogic 234X -Qlogic 234X Optical 2Gb Fibre Channel PCI cards (2312 chipset, single and dual attach). +Optical 2Gb Fibre Channel PCI cards (2312 chipset, single and dual attach). .It Qlogic 2322 -Qlogic 2322 Optical 2Gb Fibre Channel PCIe cards. +Optical 2Gb Fibre Channel PCIe cards. .It Qlogic 200 Dell branded version of the QLogic 2312. .It Qlogic 2422 -Qlogic 2422 Optical 4Gb Fibre Channel PCI cards. +Optical 4Gb Fibre Channel PCI cards. .It Qlogic 2432 -Qlogic 2432 Optical 4Gb Fibre Channel PCIe cards. +Optical 4Gb Fibre Channel PCIe cards. .It Qlogic 2532 -Qlogic 2532 Optical 8Gb Fibre Channel PCIe cards. +Optical 8Gb Fibre Channel PCIe cards. .El .Sh CONFIGURATION OPTIONS -Target mode support may be enabled with the +Target mode support for 23xx and above Fibre Channel adapters may be +enabled with the .Pp .Cd options ISP_TARGET_MODE .Pp @@ -192,7 +175,8 @@ cards in Local Loop topologies it is .Ar strongly recommended that you set this value to non-zero. .It Va hint.isp.0.role -A hint to define default role for isp instance (target, initiator, both). +A hint to define default role for isp instance (0 -- none, 1 -- target, +2 -- initiator, 3 -- both). .It Va hint.isp.0.debug A hint value for a driver debug level (see the file .Pa /usr/src/sys/dev/isp/ispvar.h @@ -236,5 +220,5 @@ Some later improvement was done by .Sh BUGS The driver currently ignores some NVRAM settings. .Pp -Target mode support works reasonably well for 23xx and above Fibre Channel -cards, but not really tested on older ones. +Fabric support for 2100 cards has been so problematic, and these cards are so +old now that it is just not worth your time to try it. Modified: stable/10/sys/dev/isp/isp.c ============================================================================== --- stable/10/sys/dev/isp/isp.c Mon Nov 30 21:54:27 2015 (r291527) +++ stable/10/sys/dev/isp/isp.c Mon Nov 30 21:55:35 2015 (r291528) @@ -1089,12 +1089,8 @@ isp_reset(ispsoftc_t *isp, int do_load_d (((uint64_t) mbs.param[17]) << 48); } } - } else if (IS_SCSI(isp)) { -#ifndef ISP_TARGET_MODE - isp->isp_fwattr = ISP_FW_ATTR_TMODE; -#else + } else { isp->isp_fwattr = 0; -#endif } isp_prt(isp, ISP_LOGCONFIG, "Board Type %s, Chip Revision 0x%x, %s F/W Revision %d.%d.%d", @@ -1907,10 +1903,10 @@ isp_fibre_init(ispsoftc_t *isp) icbp->icb_logintime = ICB_LOGIN_TOV; #ifdef ISP_TARGET_MODE - if (IS_23XX(isp) && (icbp->icb_fwoptions & ICBOPT_TGT_ENABLE)) { + if (icbp->icb_fwoptions & ICBOPT_TGT_ENABLE) { icbp->icb_lunenables = 0xffff; - icbp->icb_ccnt = DFLT_CMND_CNT; - icbp->icb_icnt = DFLT_INOT_CNT; + icbp->icb_ccnt = 0xff; + icbp->icb_icnt = 0xff; icbp->icb_lunetimeout = ICB_LUN_ENABLE_TOV; } #endif @@ -4144,14 +4140,6 @@ isp_start(XS_T *xs) } } else { sdparam *sdp = SDPARAM(isp, XS_CHANNEL(xs)); - if ((sdp->role & ISP_ROLE_INITIATOR) == 0) { - isp_prt(isp, ISP_LOGDEBUG1, - "%d.%d.%jx I am not an initiator", - XS_CHANNEL(xs), target, (uintmax_t)XS_LUN(xs)); - XS_SETERR(xs, HBA_SELTIMEOUT); - return (CMD_COMPLETE); - } - if (isp->isp_state != ISP_RUNSTATE) { isp_prt(isp, ISP_LOGERR, "Adapter not at RUNSTATE"); XS_SETERR(xs, HBA_BOTCH); @@ -4759,21 +4747,17 @@ isp_control(ispsoftc_t *isp, ispctl_t ct return (r); } case ISPCTL_CHANGE_ROLE: - { - int role, r; - - va_start(ap, ctl); - chan = va_arg(ap, int); - role = va_arg(ap, int); - va_end(ap); if (IS_FC(isp)) { + int role, r; + + va_start(ap, ctl); + chan = va_arg(ap, int); + role = va_arg(ap, int); + va_end(ap); r = isp_fc_change_role(isp, chan, role); - } else { - SDPARAM(isp, chan)->role = role; - r = 0; + return (r); } - return (r); - } + break; default: isp_prt(isp, ISP_LOGERR, "Unknown Control Opcode 0x%x", ctl); break; @@ -7446,13 +7430,10 @@ isp_setdfltsdparm(ispsoftc_t *isp) sdparam *sdp, *sdp1; sdp = SDPARAM(isp, 0); - sdp->role = GET_DEFAULT_ROLE(isp, 0); - if (IS_DUALBUS(isp)) { + if (IS_DUALBUS(isp)) sdp1 = sdp + 1; - sdp1->role = GET_DEFAULT_ROLE(isp, 1); - } else { + else sdp1 = NULL; - } /* * Establish some default parameters. @@ -7586,7 +7567,7 @@ isp_setdfltfcparm(ispsoftc_t *isp, int c /* * Establish some default parameters. */ - fcp->role = GET_DEFAULT_ROLE(isp, chan); + fcp->role = DEFAULT_ROLE(isp, chan); fcp->isp_maxalloc = ICB_DFLT_ALLOC; fcp->isp_retry_delay = ICB_DFLT_RDELAY; fcp->isp_retry_count = ICB_DFLT_RCOUNT; Modified: stable/10/sys/dev/isp/isp_freebsd.c ============================================================================== --- stable/10/sys/dev/isp/isp_freebsd.c Mon Nov 30 21:54:27 2015 (r291527) +++ stable/10/sys/dev/isp/isp_freebsd.c Mon Nov 30 21:55:35 2015 (r291528) @@ -441,11 +441,13 @@ ispioctl(struct cdev *dev, u_long c, cad if (IS_FC(isp)) { *(int *)addr = FCPARAM(isp, chan)->role; } else { - *(int *)addr = SDPARAM(isp, chan)->role; + *(int *)addr = ISP_ROLE_INITIATOR; } retval = 0; break; case ISP_SETROLE: + if (IS_SCSI(isp)) + break; nr = *(int *)addr; chan = nr >> 8; if (chan < 0 || chan >= isp->isp_nchan) { @@ -458,10 +460,7 @@ ispioctl(struct cdev *dev, u_long c, cad break; } ISP_LOCK(isp); - if (IS_FC(isp)) - *(int *)addr = FCPARAM(isp, chan)->role; - else - *(int *)addr = SDPARAM(isp, chan)->role; + *(int *)addr = FCPARAM(isp, chan)->role; retval = isp_control(isp, ISPCTL_CHANGE_ROLE, chan, nr); ISP_UNLOCK(isp); retval = 0; @@ -774,18 +773,15 @@ isp_intr_enable(void *arg) int chan; ispsoftc_t *isp = arg; ISP_LOCK(isp); - for (chan = 0; chan < isp->isp_nchan; chan++) { - if (IS_FC(isp)) { + if (IS_FC(isp)) { + for (chan = 0; chan < isp->isp_nchan; chan++) { if (FCPARAM(isp, chan)->role != ISP_ROLE_NONE) { ISP_ENABLE_INTS(isp); break; } - } else { - if (SDPARAM(isp, chan)->role != ISP_ROLE_NONE) { - ISP_ENABLE_INTS(isp); - break; - } } + } else { + ISP_ENABLE_INTS(isp); } isp->isp_osinfo.ehook_active = 0; ISP_UNLOCK(isp); @@ -831,9 +827,6 @@ isp_free_pcmd(ispsoftc_t *isp, union ccb * Put the target mode functions here, because some are inlines */ #ifdef ISP_TARGET_MODE -static ISP_INLINE void isp_tmlock(ispsoftc_t *, const char *); -static ISP_INLINE void isp_tmunlk(ispsoftc_t *); -static ISP_INLINE int is_any_lun_enabled(ispsoftc_t *, int); static ISP_INLINE int is_lun_enabled(ispsoftc_t *, int, lun_id_t); static ISP_INLINE tstate_t *get_lun_statep(ispsoftc_t *, int, lun_id_t); static ISP_INLINE tstate_t *get_lun_statep_from_tag(ispsoftc_t *, int, uint32_t); @@ -848,23 +841,16 @@ static ISP_INLINE void isp_put_ntpd(isps static cam_status create_lun_state(ispsoftc_t *, int, struct cam_path *, tstate_t **); static void destroy_lun_state(ispsoftc_t *, tstate_t *); static void isp_enable_lun(ispsoftc_t *, union ccb *); -static cam_status isp_enable_deferred_luns(ispsoftc_t *, int); -static cam_status isp_enable_deferred(ispsoftc_t *, int, lun_id_t); static void isp_disable_lun(ispsoftc_t *, union ccb *); -static int isp_enable_target_mode(ispsoftc_t *, int); -static int isp_disable_target_mode(ispsoftc_t *, int); -static void isp_ledone(ispsoftc_t *, lun_entry_t *); static timeout_t isp_refire_putback_atio; static timeout_t isp_refire_notify_ack; static void isp_complete_ctio(union ccb *); static void isp_target_putback_atio(union ccb *); enum Start_Ctio_How { FROM_CAM, FROM_TIMER, FROM_SRR, FROM_CTIO_DONE }; static void isp_target_start_ctio(ispsoftc_t *, union ccb *, enum Start_Ctio_How); -static void isp_handle_platform_atio(ispsoftc_t *, at_entry_t *); static void isp_handle_platform_atio2(ispsoftc_t *, at2_entry_t *); static void isp_handle_platform_atio7(ispsoftc_t *, at7_entry_t *); static void isp_handle_platform_ctio(ispsoftc_t *, void *); -static void isp_handle_platform_notify_scsi(ispsoftc_t *, in_entry_t *); static void isp_handle_platform_notify_fc(ispsoftc_t *, in_fcentry_t *); static void isp_handle_platform_notify_24xx(ispsoftc_t *, in_fcentry_24xx_t *); static int isp_handle_platform_target_notify_ack(ispsoftc_t *, isp_notify_t *); @@ -872,40 +858,6 @@ static void isp_handle_platform_target_t static void isp_target_mark_aborted(ispsoftc_t *, union ccb *); static void isp_target_mark_aborted_early(ispsoftc_t *, tstate_t *, uint32_t); -static ISP_INLINE void -isp_tmlock(ispsoftc_t *isp, const char *msg) -{ - while (isp->isp_osinfo.tmbusy) { - isp->isp_osinfo.tmwanted = 1; - mtx_sleep(isp, &isp->isp_lock, PRIBIO, msg, 0); - } - isp->isp_osinfo.tmbusy = 1; -} - -static ISP_INLINE void -isp_tmunlk(ispsoftc_t *isp) -{ - isp->isp_osinfo.tmbusy = 0; - if (isp->isp_osinfo.tmwanted) { - isp->isp_osinfo.tmwanted = 0; - wakeup(isp); - } -} - -static ISP_INLINE int -is_any_lun_enabled(ispsoftc_t *isp, int bus) -{ - struct tslist *lhp; - int i; - - for (i = 0; i < LUN_HASH_SIZE; i++) { - ISP_GET_PC_ADDR(isp, bus, lun_hash[i], lhp); - if (SLIST_FIRST(lhp)) - return (1); - } - return (0); -} - static ISP_INLINE int is_lun_enabled(ispsoftc_t *isp, int bus, lun_id_t lun) { @@ -1222,233 +1174,59 @@ destroy_lun_state(ispsoftc_t *isp, tstat free(tptr, M_DEVBUF); } -/* - * Enable a lun. - */ static void isp_enable_lun(ispsoftc_t *isp, union ccb *ccb) { - tstate_t *tptr = NULL; - int bus, tm_enabled, target_role; + tstate_t *tptr; + int bus; target_id_t target; lun_id_t lun; + if (!IS_FC(isp) || !ISP_CAP_TMODE(isp) || !ISP_CAP_SCCFW(isp)) { + xpt_print(ccb->ccb_h.path, "Target mode is not supported\n"); + ccb->ccb_h.status = CAM_FUNC_NOTAVAIL; + xpt_done(ccb); + return; + } /* - * We only support either a wildcard target/lun or a target ID of zero and a non-wildcard lun + * We only support either target and lun both wildcard + * or target and lun both non-wildcard. */ bus = XS_CHANNEL(ccb); target = ccb->ccb_h.target_id; lun = ccb->ccb_h.target_lun; ISP_PATH_PRT(isp, ISP_LOGTDEBUG0|ISP_LOGCONFIG, ccb->ccb_h.path, "enabling lun %jx\n", (uintmax_t)lun); - if (target == CAM_TARGET_WILDCARD && lun != CAM_LUN_WILDCARD) { - ccb->ccb_h.status = CAM_LUN_INVALID; - xpt_done(ccb); - return; - } - - if (target != CAM_TARGET_WILDCARD && lun == CAM_LUN_WILDCARD) { + if ((target == CAM_TARGET_WILDCARD) != (lun == CAM_LUN_WILDCARD)) { ccb->ccb_h.status = CAM_LUN_INVALID; xpt_done(ccb); return; } - if (isp->isp_dblev & ISP_LOGTDEBUG0) { - xpt_print(ccb->ccb_h.path, - "enabling lun 0x%jx on channel %d\n", (uintmax_t)lun, bus); - } - - /* - * Wait until we're not busy with the lun enables subsystem - */ - isp_tmlock(isp, "isp_enable_lun"); - - /* - * This is as a good a place as any to check f/w capabilities. - */ - - if (IS_FC(isp)) { - if (ISP_CAP_TMODE(isp) == 0) { - xpt_print(ccb->ccb_h.path, "firmware does not support target mode\n"); - ccb->ccb_h.status = CAM_FUNC_NOTAVAIL; - goto done; - } - /* - * We *could* handle non-SCCLUN f/w, but we'd have to - * dork with our already fragile enable/disable code. - */ - if (ISP_CAP_SCCFW(isp) == 0) { - xpt_print(ccb->ccb_h.path, "firmware not SCCLUN capable\n"); - ccb->ccb_h.status = CAM_FUNC_NOTAVAIL; - goto done; - } - - target_role = (FCPARAM(isp, bus)->role & ISP_ROLE_TARGET) != 0; - - } else { - target_role = (SDPARAM(isp, bus)->role & ISP_ROLE_TARGET) != 0; - } - /* - * Create the state pointer. - * It should not already exist. - */ + /* Create the state pointer. It should not already exist. */ tptr = get_lun_statep(isp, bus, lun); if (tptr) { ccb->ccb_h.status = CAM_LUN_ALRDY_ENA; - goto done; + xpt_done(ccb); + return; } ccb->ccb_h.status = create_lun_state(isp, bus, ccb->ccb_h.path, &tptr); if (ccb->ccb_h.status != CAM_REQ_CMP) { - goto done; - } - - /* - * We have a tricky maneuver to perform here. - * - * If target mode isn't already enabled here, - * *and* our current role includes target mode, - * we enable target mode here. - * - */ - ISP_GET_PC(isp, bus, tm_enabled, tm_enabled); - if (tm_enabled == 0 && target_role != 0) { - if (isp_enable_target_mode(isp, bus)) { - ccb->ccb_h.status = CAM_REQ_CMP_ERR; - destroy_lun_state(isp, tptr); - tptr = NULL; - goto done; - } - tm_enabled = 1; - } - - /* - * Now check to see whether this bus is in target mode already. - * - * If not, a later role change into target mode will finish the job. - */ - if (tm_enabled == 0) { - ISP_SET_PC(isp, bus, tm_enable_defer, 1); - ccb->ccb_h.status = CAM_REQ_CMP; - xpt_print(ccb->ccb_h.path, "Target Mode not enabled yet- lun enable deferred\n"); - goto done1; - } - - /* - * Enable the lun. - */ - ccb->ccb_h.status = isp_enable_deferred(isp, bus, lun); - -done: - if (ccb->ccb_h.status != CAM_REQ_CMP) { - if (tptr) { - destroy_lun_state(isp, tptr); - tptr = NULL; - } - } else { - tptr->enabled = 1; - } -done1: - if (tptr) { - rls_lun_statep(isp, tptr); + xpt_done(ccb); + return; } - /* - * And we're outta here.... - */ - isp_tmunlk(isp); + rls_lun_statep(isp, tptr); + ccb->ccb_h.status = CAM_REQ_CMP; xpt_done(ccb); } -static cam_status -isp_enable_deferred_luns(ispsoftc_t *isp, int bus) -{ - tstate_t *tptr = NULL; - struct tslist *lhp; - int i, n; - - - ISP_GET_PC(isp, bus, tm_enabled, i); - if (i == 1) { - return (CAM_REQ_CMP); - } - ISP_GET_PC(isp, bus, tm_enable_defer, i); - if (i == 0) { - return (CAM_REQ_CMP); - } - /* - * If this succeeds, it will set tm_enable - */ - if (isp_enable_target_mode(isp, bus)) { - return (CAM_REQ_CMP_ERR); - } - isp_tmlock(isp, "isp_enable_deferred_luns"); - for (n = i = 0; i < LUN_HASH_SIZE; i++) { - ISP_GET_PC_ADDR(isp, bus, lun_hash[i], lhp); - SLIST_FOREACH(tptr, lhp, next) { - tptr->hold++; - if (tptr->enabled == 0) { - if (isp_enable_deferred(isp, bus, tptr->ts_lun) == CAM_REQ_CMP) { - tptr->enabled = 1; - n++; - } - } else { - n++; - } - tptr->hold--; - } - } - isp_tmunlk(isp); - if (n == 0) { - return (CAM_REQ_CMP_ERR); - } - ISP_SET_PC(isp, bus, tm_enable_defer, 0); - return (CAM_REQ_CMP); -} - -static cam_status -isp_enable_deferred(ispsoftc_t *isp, int bus, lun_id_t lun) -{ - cam_status status; - int luns_already_enabled; - - ISP_GET_PC(isp, bus, tm_luns_enabled, luns_already_enabled); - isp_prt(isp, ISP_LOGTINFO, "%s: bus %d lun %u luns_enabled %d", __func__, bus, lun, luns_already_enabled); - if (IS_23XX(isp) || IS_24XX(isp) || - (IS_FC(isp) && luns_already_enabled)) { - status = CAM_REQ_CMP; - } else { - int cmd_cnt, not_cnt; - - if (IS_23XX(isp)) { - cmd_cnt = DFLT_CMND_CNT; - not_cnt = DFLT_INOT_CNT; - } else { - cmd_cnt = 64; - not_cnt = 8; - } - status = CAM_REQ_INPROG; - isp->isp_osinfo.rptr = &status; - if (isp_lun_cmd(isp, RQSTYPE_ENABLE_LUN, bus, lun == CAM_LUN_WILDCARD? 0 : lun, cmd_cnt, not_cnt)) { - status = CAM_RESRC_UNAVAIL; - } else { - mtx_sleep(&status, &isp->isp_lock, PRIBIO, "isp_enable_deferred", 0); - } - isp->isp_osinfo.rptr = NULL; - } - if (status == CAM_REQ_CMP) { - ISP_SET_PC(isp, bus, tm_luns_enabled, 1); - isp_prt(isp, ISP_LOGCONFIG|ISP_LOGTINFO, "bus %d lun %u now enabled for target mode", bus, lun); - } - return (status); -} - static void isp_disable_lun(ispsoftc_t *isp, union ccb *ccb) { tstate_t *tptr = NULL; int bus; - cam_status status; target_id_t target; lun_id_t lun; @@ -1457,143 +1235,24 @@ isp_disable_lun(ispsoftc_t *isp, union c lun = ccb->ccb_h.target_lun; ISP_PATH_PRT(isp, ISP_LOGTDEBUG0|ISP_LOGCONFIG, ccb->ccb_h.path, "disabling lun %jx\n", (uintmax_t)lun); - if (target == CAM_TARGET_WILDCARD && lun != CAM_LUN_WILDCARD) { + if ((target == CAM_TARGET_WILDCARD) != (lun == CAM_LUN_WILDCARD)) { ccb->ccb_h.status = CAM_LUN_INVALID; xpt_done(ccb); return; } - if (target != CAM_TARGET_WILDCARD && lun == CAM_LUN_WILDCARD) { - ccb->ccb_h.status = CAM_LUN_INVALID; + /* Find the state pointer. */ + if ((tptr = get_lun_statep(isp, bus, lun)) == NULL) { + ccb->ccb_h.status = CAM_PATH_INVALID; xpt_done(ccb); return; } - /* - * See if we're busy disabling a lun now. - */ - isp_tmlock(isp, "isp_disable_lun"); - status = CAM_REQ_INPROG; - - /* - * Find the state pointer. - */ - if ((tptr = get_lun_statep(isp, bus, lun)) == NULL) { - status = CAM_PATH_INVALID; - goto done; - } - - /* - * If we're a 24XX card, we're done. - */ - if (IS_23XX(isp) || IS_24XX(isp)) { - status = CAM_REQ_CMP; - goto done; - } - - /* - * For SCC FW, we only deal with lun zero. - */ - if (IS_FC(isp) && lun > 0) { - status = CAM_REQ_CMP; - goto done; - } - isp->isp_osinfo.rptr = &status; - if (isp_lun_cmd(isp, RQSTYPE_ENABLE_LUN, bus, lun, 0, 0)) { - status = CAM_RESRC_UNAVAIL; - } else { - mtx_sleep(&status, &isp->isp_lock, PRIBIO, "isp_disable_lun", 0); - } - isp->isp_osinfo.rptr = NULL; -done: - if (status == CAM_REQ_CMP) { - tptr->enabled = 0; - if (is_any_lun_enabled(isp, bus) == 0) { - if (isp_disable_target_mode(isp, bus)) { - status = CAM_REQ_CMP_ERR; - } - } - } - ccb->ccb_h.status = status; - if (status == CAM_REQ_CMP) { - destroy_lun_state(isp, tptr); - xpt_print(ccb->ccb_h.path, "lun now disabled for target mode\n"); - } else { - if (tptr) - rls_lun_statep(isp, tptr); - } - isp_tmunlk(isp); + destroy_lun_state(isp, tptr); + ccb->ccb_h.status = CAM_REQ_CMP; xpt_done(ccb); } -static int -isp_enable_target_mode(ispsoftc_t *isp, int bus) -{ - int tm_enabled; - - ISP_GET_PC(isp, bus, tm_enabled, tm_enabled); - if (tm_enabled != 0) { - return (0); - } - if (IS_SCSI(isp)) { - mbreg_t mbs; - MBSINIT(&mbs, MBOX_ENABLE_TARGET_MODE, MBLOGALL, 0); - mbs.param[0] = MBOX_ENABLE_TARGET_MODE; - mbs.param[1] = ENABLE_TARGET_FLAG|ENABLE_TQING_FLAG; - mbs.param[2] = bus << 7; - if (isp_control(isp, ISPCTL_RUN_MBOXCMD, &mbs) < 0 || mbs.param[0] != MBOX_COMMAND_COMPLETE) { - isp_prt(isp, ISP_LOGERR, "Unable to enable Target Role on Bus %d", bus); - return (EIO); - } - } - ISP_SET_PC(isp, bus, tm_enabled, 1); - isp_prt(isp, ISP_LOGINFO, "Target Role enabled on Bus %d", bus); - return (0); -} - -static int -isp_disable_target_mode(ispsoftc_t *isp, int bus) -{ - int tm_enabled; - - ISP_GET_PC(isp, bus, tm_enabled, tm_enabled); - if (tm_enabled == 0) { - return (0); - } - if (IS_SCSI(isp)) { - mbreg_t mbs; - MBSINIT(&mbs, MBOX_ENABLE_TARGET_MODE, MBLOGALL, 0); - mbs.param[2] = bus << 7; - if (isp_control(isp, ISPCTL_RUN_MBOXCMD, &mbs) < 0 || mbs.param[0] != MBOX_COMMAND_COMPLETE) { - isp_prt(isp, ISP_LOGERR, "Unable to disable Target Role on Bus %d", bus); - return (EIO); - } - } - ISP_SET_PC(isp, bus, tm_enabled, 0); - isp_prt(isp, ISP_LOGINFO, "Target Role disabled on Bus %d", bus); - return (0); -} - -static void -isp_ledone(ispsoftc_t *isp, lun_entry_t *lep) -{ - uint32_t *rptr; - - rptr = isp->isp_osinfo.rptr; - if (lep->le_status != LUN_OK) { - isp_prt(isp, ISP_LOGERR, "ENABLE/MODIFY LUN returned 0x%x", lep->le_status); - if (rptr) { - *rptr = CAM_REQ_CMP_ERR; - wakeup_one(rptr); - } - } else { - if (rptr) { - *rptr = CAM_REQ_CMP; - wakeup_one(rptr); - } - } -} - static void isp_target_start_ctio(ispsoftc_t *isp, union ccb *ccb, enum Start_Ctio_How how) { @@ -1891,7 +1550,7 @@ isp_target_start_ctio(ispsoftc_t *isp, u isp_prt(isp, ISP_LOGTDEBUG0, "%s: CTIO7[0x%x] seq %u nc %d CDB0=%x sstatus=0x%x flags=0x%x xfrlen=%u off=%u", __func__, cto->ct_rxid, ATPD_GET_SEQNO(cto), ATPD_GET_NCAM(cto), atp->cdb0, cto->ct_scsi_status, cto->ct_flags, xfrlen, atp->bytes_xfered); } - } else if (IS_FC(isp)) { + } else { ct2_entry_t *cto = (ct2_entry_t *) local; if (isp->isp_osinfo.sixtyfourbit) @@ -2040,41 +1699,6 @@ isp_target_start_ctio(ispsoftc_t *isp, u } isp_prt(isp, ISP_LOGTDEBUG0, "%s: CTIO2[%x] seq %u nc %d CDB0=%x scsi status %x flags %x resid %d xfrlen %u offset %u", __func__, cto->ct_rxid, ATPD_GET_SEQNO(cto), ATPD_GET_NCAM(cto), atp->cdb0, cso->scsi_status, cto->ct_flags, cto->ct_resid, cso->dxfer_len, atp->bytes_xfered); - } else { - ct_entry_t *cto = (ct_entry_t *) local; - - cto->ct_header.rqs_entry_type = RQSTYPE_CTIO; - cto->ct_header.rqs_entry_count = 1; - cto->ct_header.rqs_seqno |= ATPD_SEQ_NOTIFY_CAM; - ATPD_SET_SEQNO(cto, atp); - cto->ct_iid = cso->init_id; - cto->ct_iid |= XS_CHANNEL(ccb) << 7; - cto->ct_tgt = ccb->ccb_h.target_id; - cto->ct_lun = ccb->ccb_h.target_lun; - cto->ct_fwhandle = cso->tag_id; - if (atp->rxid) { - cto->ct_tag_val = atp->rxid; - cto->ct_flags |= CT_TQAE; - } - if (ccb->ccb_h.flags & CAM_DIS_DISCONNECT) { - cto->ct_flags |= CT_NODISC; - } - if (cso->dxfer_len == 0) { - cto->ct_flags |= CT_NO_DATA; - } else if ((cso->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) { - cto->ct_flags |= CT_DATA_IN; - } else { - cto->ct_flags |= CT_DATA_OUT; - } - if (ccb->ccb_h.flags & CAM_SEND_STATUS) { - cto->ct_flags |= CT_SENDSTATUS|CT_CCINCR; - cto->ct_scsi_status = cso->scsi_status; - cto->ct_resid = atp->orig_datalen - atp->bytes_xfered - atp->bytes_in_transit - xfrlen; - isp_prt(isp, ISP_LOGTDEBUG0, "%s: CTIO[%x] seq %u nc %d scsi status %x resid %d tag_id %x", __func__, - cto->ct_fwhandle, ATPD_GET_SEQNO(cto), ATPD_GET_NCAM(cto), cso->scsi_status, cso->resid, cso->tag_id); - } - ccb->ccb_h.flags &= ~CAM_SEND_SENSE; - cto->ct_timeout = 10; } if (isp_get_pcmd(isp, ccb)) { @@ -2104,11 +1728,8 @@ isp_target_start_ctio(ispsoftc_t *isp, u if (IS_24XX(isp)) { ct7_entry_t *cto = (ct7_entry_t *) local; cto->ct_syshandle = handle; - } else if (IS_FC(isp)) { - ct2_entry_t *cto = (ct2_entry_t *) local; - cto->ct_syshandle = handle; } else { - ct_entry_t *cto = (ct_entry_t *) local; + ct2_entry_t *cto = (ct2_entry_t *) local; cto->ct_syshandle = handle; } @@ -2167,6 +1788,7 @@ isp_target_putback_atio(union ccb *ccb) ispsoftc_t *isp; struct ccb_scsiio *cso; void *qe; + at2_entry_t local, *at = &local; isp = XS_ISP(ccb); @@ -2180,38 +1802,22 @@ isp_target_putback_atio(union ccb *ccb) } memset(qe, 0, QENTRY_LEN); cso = &ccb->csio; - if (IS_FC(isp)) { - at2_entry_t local, *at = &local; - ISP_MEMZERO(at, sizeof (at2_entry_t)); - at->at_header.rqs_entry_type = RQSTYPE_ATIO2; - at->at_header.rqs_entry_count = 1; - if (ISP_CAP_SCCFW(isp)) { - at->at_scclun = (uint16_t) ccb->ccb_h.target_lun; + ISP_MEMZERO(at, sizeof (at2_entry_t)); + at->at_header.rqs_entry_type = RQSTYPE_ATIO2; + at->at_header.rqs_entry_count = 1; + if (ISP_CAP_SCCFW(isp)) { + at->at_scclun = (uint16_t) ccb->ccb_h.target_lun; #if __FreeBSD_version < 1000700 - if (at->at_scclun >= 256) - at->at_scclun |= 0x4000; + if (at->at_scclun >= 256) + at->at_scclun |= 0x4000; #endif - } else { - at->at_lun = (uint8_t) ccb->ccb_h.target_lun; - } - at->at_status = CT_OK; - at->at_rxid = cso->tag_id; - at->at_iid = cso->ccb_h.target_id; - isp_put_atio2(isp, at, qe); } else { - at_entry_t local, *at = &local; - ISP_MEMZERO(at, sizeof (at_entry_t)); - at->at_header.rqs_entry_type = RQSTYPE_ATIO; - at->at_header.rqs_entry_count = 1; - at->at_iid = cso->init_id; - at->at_iid |= XS_CHANNEL(ccb) << 7; - at->at_tgt = cso->ccb_h.target_id; - at->at_lun = cso->ccb_h.target_lun; - at->at_status = CT_OK; - at->at_tag_val = AT_GET_TAG(cso->tag_id); - at->at_handle = AT_GET_HANDLE(cso->tag_id); - isp_put_atio(isp, at, qe); + at->at_lun = (uint8_t) ccb->ccb_h.target_lun; } + at->at_status = CT_OK; + at->at_rxid = cso->tag_id; + at->at_iid = cso->ccb_h.target_id; + isp_put_atio2(isp, at, qe); ISP_TDQE(isp, "isp_target_putback_atio", isp->isp_reqidx, qe); ISP_SYNC_REQUEST(isp); isp_complete_ctio(ccb); @@ -2226,131 +1832,6 @@ isp_complete_ctio(union ccb *ccb) } } -/* - * Handle ATIO stuff that the generic code can't. - * This means handling CDBs. - */ - -static void -isp_handle_platform_atio(ispsoftc_t *isp, at_entry_t *aep) -{ - tstate_t *tptr; - int status, bus; - struct ccb_accept_tio *atiop; - atio_private_data_t *atp; - - /* - * The firmware status (except for the QLTM_SVALID bit) - * indicates why this ATIO was sent to us. - * - * If QLTM_SVALID is set, the firmware has recommended Sense Data. - * - * If the DISCONNECTS DISABLED bit is set in the flags field, - * we're still connected on the SCSI bus. - */ - status = aep->at_status; - if ((status & ~QLTM_SVALID) == AT_PHASE_ERROR) { - /* - * Bus Phase Sequence error. We should have sense data - * suggested by the f/w. I'm not sure quite yet what - * to do about this for CAM. - */ - isp_prt(isp, ISP_LOGWARN, "PHASE ERROR"); - isp_endcmd(isp, aep, SCSI_STATUS_BUSY, 0); - return; - } - if ((status & ~QLTM_SVALID) != AT_CDB) { - isp_prt(isp, ISP_LOGWARN, "bad atio (0x%x) leaked to platform", status); - isp_endcmd(isp, aep, SCSI_STATUS_BUSY, 0); - return; - } - - bus = GET_BUS_VAL(aep->at_iid); - tptr = get_lun_statep(isp, bus, aep->at_lun); - if (tptr == NULL) { - tptr = get_lun_statep(isp, bus, CAM_LUN_WILDCARD); - if (tptr == NULL) { - /* - * Because we can't autofeed sense data back with - * a command for parallel SCSI, we can't give back - * a CHECK CONDITION. We'll give back a BUSY status - * instead. This works out okay because the only - * time we should, in fact, get this, is in the - * case that somebody configured us without the - * blackhole driver, so they get what they deserve. - */ - isp_endcmd(isp, aep, SCSI_STATUS_BUSY, 0); - return; - } - } - - atp = isp_get_atpd(isp, tptr, aep->at_handle); - atiop = (struct ccb_accept_tio *) SLIST_FIRST(&tptr->atios); - if (atiop == NULL || atp == NULL) { - /* - * Because we can't autofeed sense data back with - * a command for parallel SCSI, we can't give back - * a CHECK CONDITION. We'll give back a QUEUE FULL status - * instead. This works out okay because the only time we - * should, in fact, get this, is in the case that we've - * run out of ATIOS. - */ - xpt_print(tptr->owner, "no %s for lun %x from initiator %d\n", (atp == NULL && atiop == NULL)? "ATIOs *or* ATPS" : - ((atp == NULL)? "ATPs" : "ATIOs"), aep->at_lun, aep->at_iid); - isp_endcmd(isp, aep, SCSI_STATUS_BUSY, 0); - if (atp) { - isp_put_atpd(isp, tptr, atp); - } - rls_lun_statep(isp, tptr); - return; - } - atp->rxid = aep->at_tag_val; - atp->state = ATPD_STATE_ATIO; - SLIST_REMOVE_HEAD(&tptr->atios, sim_links.sle); - tptr->atio_count--; - ISP_PATH_PRT(isp, ISP_LOGTDEBUG2, atiop->ccb_h.path, "Take FREE ATIO count now %d\n", tptr->atio_count); - atiop->ccb_h.target_id = aep->at_tgt; - atiop->ccb_h.target_lun = aep->at_lun; - if (aep->at_flags & AT_NODISC) { - atiop->ccb_h.flags |= CAM_DIS_DISCONNECT; - } else { - atiop->ccb_h.flags &= ~CAM_DIS_DISCONNECT; - } - - if (status & QLTM_SVALID) { - size_t amt = ISP_MIN(QLTM_SENSELEN, sizeof (atiop->sense_data)); - atiop->sense_len = amt; - ISP_MEMCPY(&atiop->sense_data, aep->at_sense, amt); - } else { - atiop->sense_len = 0; - } - - atiop->init_id = GET_IID_VAL(aep->at_iid); *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***