topo = 0;
fcp->isp_topo = TOPO_NL_PORT;
isp_fclink_test(isp, waitdelay)	struct ispsoftc *isp;	int waitdelay;{	static char *toponames[] = {		"Private Loop",		"FL Port",		"N-Port to N-Port",		"F Port"	};	mbreg_t mbs;	int count, topo = -1;	u_int8_t lwfs;	fcparam *fcp;#if	defined(ISP2100_FABRIC)	isp_pdb_t pdb;#endif	fcp = isp->isp_param;	/*	 * Wait up to N microseconds for F/W to go to a ready state.	 */	lwfs = FW_CONFIG_WAIT;	for (count = 0; count < waitdelay; count += 100) {		isp_fw_state(isp);		if (lwfs != fcp->isp_fwstate) {			PRINTF("%s: Firmware State %s -> %s\n",			    isp->isp_name, isp2100_fw_statename((int)lwfs),			    isp2100_fw_statename((int)fcp->isp_fwstate));			lwfs = fcp->isp_fwstate;		}		if (fcp->isp_fwstate == FW_READY) {			break;		}		SYS_DELAY(100);	/* wait 100 microseconds */	}	/*	 * If we haven't gone to 'ready' state, return.	 */	if (fcp->isp_fwstate != FW_READY) {		return (-1);	}	/*	 * Get our Loop ID (if possible). We really need to have it.	 */	mbs.param[0] = MBOX_GET_LOOP_ID;	isp_mboxcmd(isp, &mbs);	if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {		PRINTF("%s: GET LOOP ID failed\n", isp->isp_name);		return (-1);	}	fcp->isp_loopid = mbs.param[1];	if (IS_2200(isp)) {		topo = (int) mbs.param[6];		if (topo < 0 || topo > 3)			topo = 0;	} else {		topo = 0;	}	/*	 * If we're not on a fabric, the low 8 bits will be our AL_PA.	 * If we're on a fabric, the low 8 bits will still be our AL_PA.	 */	fcp->isp_alpa = mbs.param[2];#if	defined(ISP2100_FABRIC)	fcp->isp_onfabric = 0;	if (isp_getpdb(isp, FL_PORT_ID, &pdb) == 0) {		if (IS_2100(isp))			topo = 1;		fcp->isp_portid = mbs.param[2] | (((int)mbs.param[3]) << 16);		fcp->isp_onfabric = 1;		CFGPRINTF("%s: Loop ID %d, AL_PA 0x%x, Port ID 0x%x Loop State "		    "0x%x topology '%s'\n", isp->isp_name, fcp->isp_loopid,		    fcp->isp_alpa, fcp->isp_portid, fcp->isp_loopstate,		    toponames[topo]);		/*		 * Make sure we're logged out of all fabric devices.		 */		for (count = FC_SNS_ID+1; count < MAX_FC_TARG; count++) {			struct lportdb *lp = &fcp->portdb[count];			if (lp->valid == 0 || lp->fabdev == 0)				continue;			PRINTF("%s: logging out target %d at Loop ID %d "			    "(port id 0x%x)\n", isp->isp_name, count,			    lp->loopid, lp->portid);			mbs.param[0] = MBOX_FABRIC_LOGOUT;			mbs.param[1] = lp->loopid << 8;			mbs.param[2] = 0;			mbs.param[3] = 0;			isp_mboxcmd(isp, &mbs);		}	} else#endif	CFGPRINTF("%s: Loop ID %d, ALPA 0x%x Loop State 0x%x topology '%s'\n",	    isp->isp_name, fcp->isp_loopid, fcp->isp_alpa, fcp->isp_loopstate,	    toponames[topo]);	return (0);}