FreeBSD/sys/dev/isp/isp.c
/*
 * Scan local loop for devices.
 */
Scan local loop for devices.
Scan local loop for devices .
static int
isp_scan_loop(ispsoftc_t *isp, int chan)
{
	fcparam *fcp = FCPARAM(isp, chan);
	int idx, lim, r;
	isp_pdb_t pdb;
	uint16_t *handles;
	uint16_t handle;
	if (fcp->isp_loopstate < LOOP_LTEST_DONE)
		return (-1);
	if (fcp->isp_loopstate >= LOOP_LSCAN_DONE)
		return (0);
	isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC loop scan", chan);
	fcp->isp_loopstate = LOOP_SCANNING_LOOP;
	if (TOPO_IS_FABRIC(fcp->isp_topo)) {
		if (!IS_24XX(isp)) {
			isp_fix_portids(isp, chan);
			if (fcp->isp_loopstate < LOOP_SCANNING_LOOP)
				goto abort;
		}
		isp_prt(isp, ISP_LOG_SANCFG,
		    "Chan %d FC loop scan done (no loop)", chan);
		fcp->isp_loopstate = LOOP_LSCAN_DONE;
		return (0);
	}
	handles = (uint16_t *)fcp->isp_scanscratch;
	lim = ISP_FC_SCRLEN / 2;
	r = isp_gethandles(isp, chan, handles, &lim, 1);
	if (r != 0) {
		isp_prt(isp, ISP_LOG_SANCFG,
		    "Chan %d Getting list of handles failed with %x", chan, r);
		isp_prt(isp, ISP_LOG_SANCFG,
		    "Chan %d FC loop scan done (bad)", chan);
		return (-1);
	}
	isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Got %d handles",
	    chan, lim);
	isp_mark_portdb(isp, chan);
	for (idx = 0; idx < lim; idx++) {
		handle = handles[idx];
		if (ISP_CAP_2KLOGIN(isp)) {
			if (handle >= NPH_RESERVED)
				continue;
		} else {
			if (handle >= FL_ID && handle <= SNS_ID)
				continue;
		}
		if (IS_2100(isp) || IS_2200(isp)) {
			uint64_t node_wwn = isp_get_wwn(isp, chan, handle, 1);
			if (fcp->isp_loopstate < LOOP_SCANNING_LOOP) {
abort:
				isp_prt(isp, ISP_LOG_SANCFG,
				    "Chan %d FC loop scan aborted", chan);
				return (1);
			}
			if (node_wwn == INI_NONE) {
				continue;
			}
		}
		r = isp_getpdb(isp, chan, handle, &pdb);
		if (fcp->isp_loopstate < LOOP_SCANNING_LOOP)
			goto abort;
		if (r != 0) {
			isp_prt(isp, ISP_LOGDEBUG1,
			    "Chan %d FC Scan Loop handle %d returned %x",
			    chan, handle, r);
			continue;
		}
		isp_pdb_add_update(isp, chan, &pdb);
	}
	if (fcp->isp_loopstate < LOOP_SCANNING_LOOP)
		goto abort;
	fcp->isp_loopstate = LOOP_LSCAN_DONE;
	isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC loop scan done", chan);
	return (0);
}
static int isp_scan_loop ( ispsoftc_t * isp , int chan ) { fcparam * fcp = FCPARAM ( isp , chan ) ; int idx , lim , r ; isp_pdb_t pdb ; uint16_t * handles ; uint16_t handle ; if ( fcp -> isp_loopstate < LOOP_LTEST_DONE ) return ( -1 ) ; if ( fcp -> isp_loopstate >= LOOP_LSCAN_DONE ) return ( 0 ) ; isp_prt ( isp , ISP_LOG_SANCFG , " " , chan ) ; fcp -> isp_loopstate = LOOP_SCANNING_LOOP ; if ( TOPO_IS_FABRIC ( fcp -> isp_topo ) ) { if ( ! IS_24XX ( isp ) ) { isp_fix_portids ( isp , chan ) ; if ( fcp -> isp_loopstate < LOOP_SCANNING_LOOP ) goto abort ; } isp_prt ( isp , ISP_LOG_SANCFG , " " , chan ) ; fcp -> isp_loopstate = LOOP_LSCAN_DONE ; return ( 0 ) ; } handles = ( uint16_t * ) fcp -> isp_scanscratch ; lim = ISP_FC_SCRLEN / 2 ; r = isp_gethandles ( isp , chan , handles , & lim , 1 ) ; if ( r != 0 ) { isp_prt ( isp , ISP_LOG_SANCFG , " " , chan , r ) ; isp_prt ( isp , ISP_LOG_SANCFG , " " , chan ) ; return ( -1 ) ; } isp_prt ( isp , ISP_LOG_SANCFG , " " , chan , lim ) ; isp_mark_portdb ( isp , chan ) ; for ( idx = 0 ; idx < lim ; idx ++ ) { handle = handles [ idx ] ; if ( ISP_CAP_2KLOGIN ( isp ) ) { if ( handle >= NPH_RESERVED ) continue ; } else { if ( handle >= FL_ID && handle <= SNS_ID ) continue ; } if ( IS_2100 ( isp ) || IS_2200 ( isp ) ) { uint64_t node_wwn = isp_get_wwn ( isp , chan , handle , 1 ) ; if ( fcp -> isp_loopstate < LOOP_SCANNING_LOOP ) { abort : isp_prt ( isp , ISP_LOG_SANCFG , " " , chan ) ; return ( 1 ) ; } if ( node_wwn == INI_NONE ) { continue ; } } r = isp_getpdb ( isp , chan , handle , & pdb ) ; if ( fcp -> isp_loopstate < LOOP_SCANNING_LOOP ) goto abort ; if ( r != 0 ) { isp_prt ( isp , ISP_LOGDEBUG1 , " " , chan , handle , r ) ; continue ; } isp_pdb_add_update ( isp , chan , & pdb ) ; } if ( fcp -> isp_loopstate < LOOP_SCANNING_LOOP ) goto abort ; fcp -> isp_loopstate = LOOP_LSCAN_DONE ; isp_prt ( isp , ISP_LOG_SANCFG , " " , chan ) ; return ( 0 ) ; }
Scan local loop for devices.
Scan local loop for devices .
/*
	 * Run through the list and get the port database info for each one.
	 */ /*
		 * Don't scan "special" ids.
		 */ /*
		 * In older cards with older f/w GET_PORT_DATABASE has been
		 * known to hang. This trick gets around that problem.
		 */ /*
		 * Get the port database entity for this index.
		 */