FreeBSD/sys/dev/cxgbe/common/t4_hw.c
/**
 *	t4_cim_read_la - read CIM LA capture buffer
 *	@adap: the adapter
 *	@la_buf: where to store the LA data
 *	@wrptr: the HW write pointer within the capture buffer
 *
 *	Reads the contents of the CIM LA buffer with the most recent entry at
 *	the end	of the returned data and with the entry at @wrptr first.
 *	We try to leave the LA in the running state we find it in.
 */
read CIM LA capture buffer
@adap: the adapter
@la_buf: where to store the LA data
@wrptr: the HW write pointer within the capture buffer

Reads the contents of the CIM LA buffer with the most recent entry at
the end of the returned data and with the entry at @wrptr first.
We try to leave the LA in the running state we find it in.
read CIM LA capture buffer @adap : the adapter @la_buf : where to store the LA data @wrptr : the HW write pointer within the capture buffer Reads the contents of the CIM LA buffer with the most recent entry at the end of the returned data and with the entry at @wrptr first . We try to leave the LA in the running state we find it in .
int t4_cim_read_la(struct adapter *adap, u32 *la_buf, unsigned int *wrptr)
{
	int i, ret;
	unsigned int cfg, val, idx;
	ret = t4_cim_read(adap, A_UP_UP_DBG_LA_CFG, 1, &cfg);
	if (ret)
		return ret;
	if (cfg & F_UPDBGLAEN) {	
		ret = t4_cim_write1(adap, A_UP_UP_DBG_LA_CFG, 0);
		if (ret)
			return ret;
	}
	ret = t4_cim_read(adap, A_UP_UP_DBG_LA_CFG, 1, &val);
	if (ret)
		goto restart;
	idx = G_UPDBGLAWRPTR(val);
	if (wrptr)
		*wrptr = idx;
	for (i = 0; i < adap->params.cim_la_size; i++) {
		ret = t4_cim_write1(adap, A_UP_UP_DBG_LA_CFG,
				    V_UPDBGLARDPTR(idx) | F_UPDBGLARDEN);
		if (ret)
			break;
		ret = t4_cim_read(adap, A_UP_UP_DBG_LA_CFG, 1, &val);
		if (ret)
			break;
		if (val & F_UPDBGLARDEN) {
			ret = -ETIMEDOUT;
			break;
		}
		ret = t4_cim_read(adap, A_UP_UP_DBG_LA_DATA, 1, &la_buf[i]);
		if (ret)
			break;
		idx = (idx + 1) & M_UPDBGLARDPTR;
		if (is_t6(adap))
			while ((idx & 0xf) > 9)
				idx = (idx + 1) % M_UPDBGLARDPTR;
	}
restart:
	if (cfg & F_UPDBGLAEN) {
		int r = t4_cim_write1(adap, A_UP_UP_DBG_LA_CFG,
				      cfg & ~F_UPDBGLARDEN);
		if (!ret)
			ret = r;
	}
	return ret;
}
int t4_cim_read_la ( struct adapter * adap , u32 * la_buf , unsigned int * wrptr ) { int i , ret ; unsigned int cfg , val , idx ; ret = t4_cim_read ( adap , A_UP_UP_DBG_LA_CFG , 1 , & cfg ) ; if ( ret ) return ret ; if ( cfg & F_UPDBGLAEN ) { ret = t4_cim_write1 ( adap , A_UP_UP_DBG_LA_CFG , 0 ) ; if ( ret ) return ret ; } ret = t4_cim_read ( adap , A_UP_UP_DBG_LA_CFG , 1 , & val ) ; if ( ret ) goto restart ; idx = G_UPDBGLAWRPTR ( val ) ; if ( wrptr ) * wrptr = idx ; for ( i = 0 ; i < adap -> params . cim_la_size ; i ++ ) { ret = t4_cim_write1 ( adap , A_UP_UP_DBG_LA_CFG , V_UPDBGLARDPTR ( idx ) | F_UPDBGLARDEN ) ; if ( ret ) break ; ret = t4_cim_read ( adap , A_UP_UP_DBG_LA_CFG , 1 , & val ) ; if ( ret ) break ; if ( val & F_UPDBGLARDEN ) { ret = - ETIMEDOUT ; break ; } ret = t4_cim_read ( adap , A_UP_UP_DBG_LA_DATA , 1 , & la_buf [ i ] ) ; if ( ret ) break ; idx = ( idx + 1 ) & M_UPDBGLARDPTR ; if ( is_t6 ( adap ) ) while ( ( idx & 0xf ) > 9 ) idx = ( idx + 1 ) % M_UPDBGLARDPTR ; } restart : if ( cfg & F_UPDBGLAEN ) { int r = t4_cim_write1 ( adap , A_UP_UP_DBG_LA_CFG , cfg & ~ F_UPDBGLARDEN ) ; if ( ! ret ) ret = r ; } return ret ; }
t4_cim_read_la - read CIM LA capture buffer
      @adap: the adapter
      @la_buf: where to store the LA data
      @wrptr: the HW write pointer within the capture buffer
t4_cim_read_la - read CIM LA capture buffer @adap : the adapter @la_buf : where to store the LA data @wrptr : the HW write pointer within the capture buffer
/* LA is running, freeze it */ /* address can't exceed 0xfff (UpDbgLaRdPtr is of 12-bits) */ /*
		 * Bits 0-3 of UpDbgLaRdPtr can be between 0000 to 1001 to
		 * identify the 32-bit portion of the full 312-bit data
		 */