Date: Mon, 5 Oct 2015 08:30:50 +0000 (UTC) From: Alexander Motin <mav@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r288713 - in stable/10/sys: cam/ctl dev/isp Message-ID: <201510050830.t958UoNO005589@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mav Date: Mon Oct 5 08:30:49 2015 New Revision: 288713 URL: https://svnweb.freebsd.org/changeset/base/288713 Log: MFC r285155: Make first step toward supporting target and initiator roles same time. To avoid conflicts between target and initiator devices in CAM, make CTL use target ID reported by HBA as its initiator_id in XPT_PATH_INQ. That target ID is known to never be used for initiator role, so it won't conflict. For Fibre Channel and FireWire HBAs this specific ID choice is irrelevant since all target IDs there are virtual. Same time for SPI HBAs it seems could be even requirement to use same target ID for both initiator and target roles. While there are some more things to polish in isp(4) driver, first tests of using both roles same time on the same port appeared successfull: # camcontrol devlist -v scbus0 on isp0 bus 0: <FREEBSD CTLDISK 0001> at scbus0 target 1 lun 0 (da20,pass21) <> at scbus0 target 256 lun 0 (ctl0) <> at scbus0 target -1 lun ffffffff (ctl1) Modified: stable/10/sys/cam/ctl/scsi_ctl.c stable/10/sys/dev/isp/isp_freebsd.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cam/ctl/scsi_ctl.c ============================================================================== --- stable/10/sys/cam/ctl/scsi_ctl.c Mon Oct 5 08:29:31 2015 (r288712) +++ stable/10/sys/cam/ctl/scsi_ctl.c Mon Oct 5 08:30:49 2015 (r288713) @@ -75,6 +75,7 @@ __FBSDID("$FreeBSD$"); struct ctlfe_softc { struct ctl_port port; path_id_t path_id; + target_id_t target_id; u_int maxio; struct cam_sim *sim; char port_name[DEV_IDLEN]; @@ -357,6 +358,7 @@ ctlfeasync(void *callback_arg, uint32_t } softc->path_id = cpi->ccb_h.path_id; + softc->target_id = cpi->initiator_id; softc->sim = xpt_path_sim(path); if (cpi->maxio != 0) softc->maxio = cpi->maxio; @@ -1557,6 +1559,8 @@ ctlfe_onoffline(void *arg, int online) } ccb = xpt_alloc_ccb(); xpt_setup_ccb(&ccb->ccb_h, path, CAM_PRIORITY_NONE); + ccb->ccb_h.func_code = XPT_GET_SIM_KNOB; + xpt_action(ccb); /* * Copan WWN format: @@ -1570,15 +1574,7 @@ ctlfe_onoffline(void *arg, int online) * 3 == NL-Port * Bits 7-0: 0 == Node Name, >0 == Port Number */ - if (online != 0) { - - ccb->ccb_h.func_code = XPT_GET_SIM_KNOB; - - - xpt_action(ccb); - - if ((ccb->knob.xport_specific.valid & KNOB_VALID_ADDRESS) != 0){ #ifdef RANDOM_WWNN uint64_t random_bits; @@ -1677,9 +1673,9 @@ ctlfe_onoffline(void *arg, int online) ccb->knob.xport_specific.valid |= KNOB_VALID_ADDRESS; if (online != 0) - ccb->knob.xport_specific.fc.role = KNOB_ROLE_TARGET; + ccb->knob.xport_specific.fc.role |= KNOB_ROLE_TARGET; else - ccb->knob.xport_specific.fc.role = KNOB_ROLE_NONE; + ccb->knob.xport_specific.fc.role &= ~KNOB_ROLE_TARGET; xpt_action(ccb); @@ -1809,7 +1805,7 @@ ctlfe_lun_enable(void *arg, int lun_id) bus_softc = (struct ctlfe_softc *)arg; status = xpt_create_path(&path, /*periph*/ NULL, - bus_softc->path_id, 0, lun_id); + bus_softc->path_id, bus_softc->target_id, lun_id); /* XXX KDM need some way to return status to CTL here? */ if (status != CAM_REQ_CMP) { printf("%s: could not create path, status %#x\n", __func__, Modified: stable/10/sys/dev/isp/isp_freebsd.c ============================================================================== --- stable/10/sys/dev/isp/isp_freebsd.c Mon Oct 5 08:29:31 2015 (r288712) +++ stable/10/sys/dev/isp/isp_freebsd.c Mon Oct 5 08:30:49 2015 (r288713) @@ -462,24 +462,11 @@ ispioctl(struct cdev *dev, u_long c, cad retval = EINVAL; break; } - if (IS_FC(isp)) { - /* - * We don't really support dual role at present on FC cards. - * - * We should, but a bunch of things are currently broken, - * so don't allow it. - */ - if (nr == ISP_ROLE_BOTH) { - isp_prt(isp, ISP_LOGERR, "cannot support dual role at present"); - retval = EINVAL; - break; - } - ISP_LOCK(isp); + ISP_LOCK(isp); + if (IS_FC(isp)) *(int *)addr = FCPARAM(isp, chan)->role; - } else { - ISP_LOCK(isp); + else *(int *)addr = SDPARAM(isp, chan)->role; - } retval = isp_control(isp, ISPCTL_CHANGE_ROLE, chan, nr); ISP_UNLOCK(isp); retval = 0; @@ -1262,11 +1249,6 @@ isp_enable_lun(ispsoftc_t *isp, union cc 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 %u\n", lun); - if (target != CAM_TARGET_WILDCARD && target != 0) { - ccb->ccb_h.status = CAM_TID_INVALID; - xpt_done(ccb); - return; - } if (target == CAM_TARGET_WILDCARD && lun != CAM_LUN_WILDCARD) { ccb->ccb_h.status = CAM_LUN_INVALID; xpt_done(ccb); @@ -1479,12 +1461,6 @@ isp_disable_lun(ispsoftc_t *isp, union c target = ccb->ccb_h.target_id; lun = ccb->ccb_h.target_lun; ISP_PATH_PRT(isp, ISP_LOGTDEBUG0|ISP_LOGCONFIG, ccb->ccb_h.path, "disabling lun %u\n", lun); - if (target != CAM_TARGET_WILDCARD && target != 0) { - ccb->ccb_h.status = CAM_TID_INVALID; - xpt_done(ccb); - return; - } - if (target == CAM_TARGET_WILDCARD && lun != CAM_LUN_WILDCARD) { ccb->ccb_h.status = CAM_LUN_INVALID; xpt_done(ccb); @@ -5437,21 +5413,10 @@ isp_action(struct cam_sim *sim, union cc } break; case KNOB_ROLE_BOTH: -#if 0 if (fcp->role != ISP_ROLE_BOTH) { rchange = 1; newrole = ISP_ROLE_BOTH; } -#else - /* - * We don't really support dual role at present on FC cards. - * - * We should, but a bunch of things are currently broken, - * so don't allow it. - */ - isp_prt(isp, ISP_LOGERR, "cannot support dual role at present"); - ccb->ccb_h.status = CAM_REQ_INVALID; -#endif break; } if (rchange) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201510050830.t958UoNO005589>