Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 30 Dec 2015 11:49:04 +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: r292919 - stable/10/sys/dev/isp
Message-ID:  <201512301149.tBUBn4I7048198@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Wed Dec 30 11:49:04 2015
New Revision: 292919
URL: https://svnweb.freebsd.org/changeset/base/292919

Log:
  MFC r292715: Clear virtual port's port database when disabling it.
  
  Previously it was done only on full chip reinit, that caused old ports
  resurrect in case of virtual port reenabling.

Modified:
  stable/10/sys/dev/isp/isp.c
  stable/10/sys/dev/isp/isp_library.c
  stable/10/sys/dev/isp/isp_library.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/isp/isp.c
==============================================================================
--- stable/10/sys/dev/isp/isp.c	Wed Dec 30 11:48:17 2015	(r292918)
+++ stable/10/sys/dev/isp/isp.c	Wed Dec 30 11:49:04 2015	(r292919)
@@ -2344,6 +2344,159 @@ isp_fibre_init_2400(ispsoftc_t *isp)
 	isp->isp_state = ISP_RUNSTATE;
 }
 
+static int
+isp_fc_enable_vp(ispsoftc_t *isp, int chan)
+{
+	fcparam *fcp = FCPARAM(isp, chan);
+	mbreg_t mbs;
+	vp_modify_t *vp;
+	uint8_t qe[QENTRY_LEN], *scp;
+
+	ISP_MEMZERO(qe, QENTRY_LEN);
+	if (FC_SCRATCH_ACQUIRE(isp, chan)) {
+		return (EBUSY);
+	}
+	scp = fcp->isp_scratch;
+
+	/* Build a VP MODIFY command in memory */
+	vp = (vp_modify_t *) qe;
+	vp->vp_mod_hdr.rqs_entry_type = RQSTYPE_VP_MODIFY;
+	vp->vp_mod_hdr.rqs_entry_count = 1;
+	vp->vp_mod_cnt = 1;
+	vp->vp_mod_idx0 = chan;
+	vp->vp_mod_cmd = VP_MODIFY_ENA;
+	vp->vp_mod_ports[0].options = ICB2400_VPOPT_ENABLED |
+	    ICB2400_VPOPT_ENA_SNSLOGIN;
+	if (fcp->role & ISP_ROLE_INITIATOR) {
+		vp->vp_mod_ports[0].options |= ICB2400_VPOPT_INI_ENABLE;
+	}
+	if ((fcp->role & ISP_ROLE_TARGET) == 0) {
+		vp->vp_mod_ports[0].options |= ICB2400_VPOPT_TGT_DISABLE;
+	}
+	if (fcp->isp_loopid < LOCAL_LOOP_LIM) {
+		vp->vp_mod_ports[0].loopid = fcp->isp_loopid;
+		if (isp->isp_confopts & ISP_CFG_OWNLOOPID)
+			vp->vp_mod_ports[0].options |=
+			    ICB2400_VPOPT_HARD_ADDRESS;
+		else
+			vp->vp_mod_ports[0].options |=
+			    ICB2400_VPOPT_PREV_ADDRESS;
+	}
+	MAKE_NODE_NAME_FROM_WWN(vp->vp_mod_ports[0].wwpn, fcp->isp_wwpn);
+	MAKE_NODE_NAME_FROM_WWN(vp->vp_mod_ports[0].wwnn, fcp->isp_wwnn);
+	isp_put_vp_modify(isp, vp, (vp_modify_t *) scp);
+
+	/* Build a EXEC IOCB A64 command that points to the VP MODIFY command */
+	MBSINIT(&mbs, MBOX_EXEC_COMMAND_IOCB_A64, MBLOGALL, 0);
+	mbs.param[1] = QENTRY_LEN;
+	mbs.param[2] = DMA_WD1(fcp->isp_scdma);
+	mbs.param[3] = DMA_WD0(fcp->isp_scdma);
+	mbs.param[6] = DMA_WD3(fcp->isp_scdma);
+	mbs.param[7] = DMA_WD2(fcp->isp_scdma);
+	MEMORYBARRIER(isp, SYNC_SFORDEV, 0, 2 * QENTRY_LEN, chan);
+	isp_control(isp, ISPCTL_RUN_MBOXCMD, &mbs);
+	if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
+		FC_SCRATCH_RELEASE(isp, chan);
+		return (EIO);
+	}
+	MEMORYBARRIER(isp, SYNC_SFORCPU, QENTRY_LEN, QENTRY_LEN, chan);
+	isp_get_vp_modify(isp, (vp_modify_t *)&scp[QENTRY_LEN], vp);
+
+	FC_SCRATCH_RELEASE(isp, chan);
+
+	if (vp->vp_mod_status != VP_STS_OK) {
+		isp_prt(isp, ISP_LOGERR, "%s: VP_MODIFY of Chan %d failed with status %d", __func__, chan, vp->vp_mod_status);
+		return (EIO);
+	}
+	return (0);
+}
+
+static int
+isp_fc_disable_vp(ispsoftc_t *isp, int chan)
+{
+	fcparam *fcp = FCPARAM(isp, chan);
+	mbreg_t mbs;
+	vp_ctrl_info_t *vp;
+	uint8_t qe[QENTRY_LEN], *scp;
+
+	ISP_MEMZERO(qe, QENTRY_LEN);
+	if (FC_SCRATCH_ACQUIRE(isp, chan)) {
+		return (EBUSY);
+	}
+	scp = fcp->isp_scratch;
+
+	/* Build a VP CTRL command in memory */
+	vp = (vp_ctrl_info_t *) qe;
+	vp->vp_ctrl_hdr.rqs_entry_type = RQSTYPE_VP_CTRL;
+	vp->vp_ctrl_hdr.rqs_entry_count = 1;
+	if (ISP_CAP_VP0(isp)) {
+		vp->vp_ctrl_status = 1;
+	} else {
+		vp->vp_ctrl_status = 0;
+		chan--;	/* VP0 can not be controlled in this case. */
+	}
+	vp->vp_ctrl_command = VP_CTRL_CMD_DISABLE_VP_LOGO_ALL;
+	vp->vp_ctrl_vp_count = 1;
+	vp->vp_ctrl_idmap[chan / 16] |= (1 << chan % 16);
+	isp_put_vp_ctrl_info(isp, vp, (vp_ctrl_info_t *) scp);
+
+	/* Build a EXEC IOCB A64 command that points to the VP CTRL command */
+	MBSINIT(&mbs, MBOX_EXEC_COMMAND_IOCB_A64, MBLOGALL, 0);
+	mbs.param[1] = QENTRY_LEN;
+	mbs.param[2] = DMA_WD1(fcp->isp_scdma);
+	mbs.param[3] = DMA_WD0(fcp->isp_scdma);
+	mbs.param[6] = DMA_WD3(fcp->isp_scdma);
+	mbs.param[7] = DMA_WD2(fcp->isp_scdma);
+	MEMORYBARRIER(isp, SYNC_SFORDEV, 0, 2 * QENTRY_LEN, chan);
+	isp_control(isp, ISPCTL_RUN_MBOXCMD, &mbs);
+	if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
+		FC_SCRATCH_RELEASE(isp, chan);
+		return (EIO);
+	}
+	MEMORYBARRIER(isp, SYNC_SFORCPU, QENTRY_LEN, QENTRY_LEN, chan);
+	isp_get_vp_ctrl_info(isp, (vp_ctrl_info_t *)&scp[QENTRY_LEN], vp);
+
+	FC_SCRATCH_RELEASE(isp, chan);
+
+	if (vp->vp_ctrl_status != 0) {
+		isp_prt(isp, ISP_LOGERR,
+		    "%s: VP_CTRL of Chan %d failed with status %d %d",
+		    __func__, chan, vp->vp_ctrl_status, vp->vp_ctrl_index_fail);
+		return (EIO);
+	}
+	return (0);
+}
+
+static int
+isp_fc_change_role(ispsoftc_t *isp, int chan, int new_role)
+{
+	fcparam *fcp = FCPARAM(isp, chan);
+	int i, was, res = 0;
+
+	if (chan >= isp->isp_nchan) {
+		isp_prt(isp, ISP_LOGWARN, "%s: bad channel %d", __func__, chan);
+		return (ENXIO);
+	}
+	if (fcp->role == new_role)
+		return (0);
+	for (was = 0, i = 0; i < isp->isp_nchan; i++) {
+		if (FCPARAM(isp, i)->role != ISP_ROLE_NONE)
+			was++;
+	}
+	if (was == 0 || (was == 1 && fcp->role != ISP_ROLE_NONE)) {
+		fcp->role = new_role;
+		return (isp_reinit(isp, 0));
+	}
+	if (fcp->role != ISP_ROLE_NONE) {
+		res = isp_fc_disable_vp(isp, chan);
+		isp_clear_portdb(isp, chan);
+	}
+	fcp->role = new_role;
+	if (fcp->role != ISP_ROLE_NONE)
+		res = isp_fc_enable_vp(isp, chan);
+	return (res);
+}
+
 static void
 isp_clear_portdb(ispsoftc_t *isp, int chan)
 {

Modified: stable/10/sys/dev/isp/isp_library.c
==============================================================================
--- stable/10/sys/dev/isp/isp_library.c	Wed Dec 30 11:48:17 2015	(r292918)
+++ stable/10/sys/dev/isp/isp_library.c	Wed Dec 30 11:49:04 2015	(r292919)
@@ -573,168 +573,6 @@ isp_fc_toponame(fcparam *fcp)
 	}
 }
 
-static int
-isp_fc_enable_vp(ispsoftc_t *isp, int chan)
-{
-	fcparam *fcp = FCPARAM(isp, chan);
-	mbreg_t mbs;
-	vp_modify_t *vp;
-	uint8_t qe[QENTRY_LEN], *scp;
-
-	ISP_MEMZERO(qe, QENTRY_LEN);
-	if (FC_SCRATCH_ACQUIRE(isp, chan)) {
-		return (EBUSY);
-	}
-	scp = fcp->isp_scratch;
-
-	/*
-	 * Build a VP MODIFY command in memory
-	 */
-	vp = (vp_modify_t *) qe;
-	vp->vp_mod_hdr.rqs_entry_type = RQSTYPE_VP_MODIFY;
-	vp->vp_mod_hdr.rqs_entry_count = 1;
-	vp->vp_mod_cnt = 1;
-	vp->vp_mod_idx0 = chan;
-	vp->vp_mod_cmd = VP_MODIFY_ENA;
-	vp->vp_mod_ports[0].options = ICB2400_VPOPT_ENABLED |
-	    ICB2400_VPOPT_ENA_SNSLOGIN;
-	if (fcp->role & ISP_ROLE_INITIATOR) {
-		vp->vp_mod_ports[0].options |= ICB2400_VPOPT_INI_ENABLE;
-	}
-	if ((fcp->role & ISP_ROLE_TARGET) == 0) {
-		vp->vp_mod_ports[0].options |= ICB2400_VPOPT_TGT_DISABLE;
-	}
-	if (fcp->isp_loopid < LOCAL_LOOP_LIM) {
-		vp->vp_mod_ports[0].loopid = fcp->isp_loopid;
-		if (isp->isp_confopts & ISP_CFG_OWNLOOPID)
-			vp->vp_mod_ports[0].options |=
-			    ICB2400_VPOPT_HARD_ADDRESS;
-		else
-			vp->vp_mod_ports[0].options |=
-			    ICB2400_VPOPT_PREV_ADDRESS;
-	}
-	MAKE_NODE_NAME_FROM_WWN(vp->vp_mod_ports[0].wwpn, fcp->isp_wwpn);
-	MAKE_NODE_NAME_FROM_WWN(vp->vp_mod_ports[0].wwnn, fcp->isp_wwnn);
-	isp_put_vp_modify(isp, vp, (vp_modify_t *) scp);
-
-	/*
-	 * Build a EXEC IOCB A64 command that points to the VP MODIFY command
-	 */
-	MBSINIT(&mbs, MBOX_EXEC_COMMAND_IOCB_A64, MBLOGALL, 0);
-	mbs.param[1] = QENTRY_LEN;
-	mbs.param[2] = DMA_WD1(fcp->isp_scdma);
-	mbs.param[3] = DMA_WD0(fcp->isp_scdma);
-	mbs.param[6] = DMA_WD3(fcp->isp_scdma);
-	mbs.param[7] = DMA_WD2(fcp->isp_scdma);
-	MEMORYBARRIER(isp, SYNC_SFORDEV, 0, 2 * QENTRY_LEN, chan);
-	isp_control(isp, ISPCTL_RUN_MBOXCMD, &mbs);
-	if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
-		FC_SCRATCH_RELEASE(isp, chan);
-		return (EIO);
-	}
-	MEMORYBARRIER(isp, SYNC_SFORCPU, QENTRY_LEN, QENTRY_LEN, chan);
-	isp_get_vp_modify(isp, (vp_modify_t *)&scp[QENTRY_LEN], vp);
-
-	FC_SCRATCH_RELEASE(isp, chan);
-
-	if (vp->vp_mod_status != VP_STS_OK) {
-		isp_prt(isp, ISP_LOGERR, "%s: VP_MODIFY of Chan %d failed with status %d", __func__, chan, vp->vp_mod_status);
-		return (EIO);
-	}
-	return (0);
-}
-
-static int
-isp_fc_disable_vp(ispsoftc_t *isp, int chan)
-{
-	fcparam *fcp = FCPARAM(isp, chan);
-	mbreg_t mbs;
-	vp_ctrl_info_t *vp;
-	uint8_t qe[QENTRY_LEN], *scp;
-
-	ISP_MEMZERO(qe, QENTRY_LEN);
-	if (FC_SCRATCH_ACQUIRE(isp, chan)) {
-		return (EBUSY);
-	}
-	scp = fcp->isp_scratch;
-
-	/*
-	 * Build a VP CTRL command in memory
-	 */
-	vp = (vp_ctrl_info_t *) qe;
-	vp->vp_ctrl_hdr.rqs_entry_type = RQSTYPE_VP_CTRL;
-	vp->vp_ctrl_hdr.rqs_entry_count = 1;
-	if (ISP_CAP_VP0(isp)) {
-		vp->vp_ctrl_status = 1;
-	} else {
-		vp->vp_ctrl_status = 0;
-		chan--;	/* VP0 can not be controlled in this case. */
-	}
-	vp->vp_ctrl_command = VP_CTRL_CMD_DISABLE_VP_LOGO_ALL;
-	vp->vp_ctrl_vp_count = 1;
-	vp->vp_ctrl_idmap[chan / 16] |= (1 << chan % 16);
-	isp_put_vp_ctrl_info(isp, vp, (vp_ctrl_info_t *) scp);
-
-	/*
-	 * Build a EXEC IOCB A64 command that points to the VP CTRL command
-	 */
-	MBSINIT(&mbs, MBOX_EXEC_COMMAND_IOCB_A64, MBLOGALL, 0);
-	mbs.param[1] = QENTRY_LEN;
-	mbs.param[2] = DMA_WD1(fcp->isp_scdma);
-	mbs.param[3] = DMA_WD0(fcp->isp_scdma);
-	mbs.param[6] = DMA_WD3(fcp->isp_scdma);
-	mbs.param[7] = DMA_WD2(fcp->isp_scdma);
-	MEMORYBARRIER(isp, SYNC_SFORDEV, 0, 2 * QENTRY_LEN, chan);
-	isp_control(isp, ISPCTL_RUN_MBOXCMD, &mbs);
-	if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
-		FC_SCRATCH_RELEASE(isp, chan);
-		return (EIO);
-	}
-	MEMORYBARRIER(isp, SYNC_SFORCPU, QENTRY_LEN, QENTRY_LEN, chan);
-	isp_get_vp_ctrl_info(isp, (vp_ctrl_info_t *)&scp[QENTRY_LEN], vp);
-
-	FC_SCRATCH_RELEASE(isp, chan);
-
-	if (vp->vp_ctrl_status != 0) {
-		isp_prt(isp, ISP_LOGERR,
-		    "%s: VP_CTRL of Chan %d failed with status %d %d",
-		    __func__, chan, vp->vp_ctrl_status, vp->vp_ctrl_index_fail);
-		return (EIO);
-	}
-	return (0);
-}
-
-/*
- * Change Roles
- */
-int
-isp_fc_change_role(ispsoftc_t *isp, int chan, int new_role)
-{
-	fcparam *fcp = FCPARAM(isp, chan);
-	int i, was, res = 0;
-
-	if (chan >= isp->isp_nchan) {
-		isp_prt(isp, ISP_LOGWARN, "%s: bad channel %d", __func__, chan);
-		return (ENXIO);
-	}
-	if (fcp->role == new_role)
-		return (0);
-	for (was = 0, i = 0; i < isp->isp_nchan; i++) {
-		if (FCPARAM(isp, i)->role != ISP_ROLE_NONE)
-			was++;
-	}
-	if (was == 0 || (was == 1 && fcp->role != ISP_ROLE_NONE)) {
-		fcp->role = new_role;
-		return (isp_reinit(isp, 0));
-	}
-	if (fcp->role != ISP_ROLE_NONE)
-		res = isp_fc_disable_vp(isp, chan);
-	fcp->role = new_role;
-	if (fcp->role != ISP_ROLE_NONE)
-		res = isp_fc_enable_vp(isp, chan);
-	return (res);
-}
-
 void
 isp_clear_commands(ispsoftc_t *isp)
 {

Modified: stable/10/sys/dev/isp/isp_library.h
==============================================================================
--- stable/10/sys/dev/isp/isp_library.h	Wed Dec 30 11:48:17 2015	(r292918)
+++ stable/10/sys/dev/isp/isp_library.h	Wed Dec 30 11:49:04 2015	(r292919)
@@ -72,9 +72,6 @@ const char *isp_fc_fw_statename(int);
 const char *isp_fc_loop_statename(int);
 const char *isp_fc_toponame(fcparam *);
 
-int isp_fc_change_role(ispsoftc_t *, int, int);
-
-
 /*
  * Cleanup
  */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201512301149.tBUBn4I7048198>