FreeBSD/sys/dev/cxgbe/common/t4_hw.c
/**
 *	t4_read_cim_obq - read the contents of a CIM outbound queue
 *	@adap: the adapter
 *	@qid: the queue index
 *	@data: where to store the queue contents
 *	@n: capacity of @data in 32-bit words
 *
 *	Reads the contents of the selected CIM queue starting at address 0 up
 *	to the capacity of @data.  @n must be a multiple of 4.  Returns < 0 on
 *	error and the number of 32-bit words actually read on success.
 */


Reads the contents of the selected CIM queue starting at address 0 up
to the capacity of @data.  @n must be a multiple of 4.  Returns < 0 on
error and the number of 32-bit words actually read on success.
Reads the contents of the selected CIM queue starting at address 0 up to the capacity of @data . @n must be a multiple of 4 . Returns < 0 on error and the number of 32 - bit words actually read on success .
int t4_read_cim_obq(struct adapter *adap, unsigned int qid, u32 *data, size_t n)
{
	int i, err;
	unsigned int addr, v, nwords;
	int cim_num_obq = adap->chip_params->cim_num_obq;
	if ((qid > (cim_num_obq - 1)) || (n & 3))
		return -EINVAL;
	t4_write_reg(adap, A_CIM_QUEUE_CONFIG_REF, F_OBQSELECT |
		     V_QUENUMSELECT(qid));
	v = t4_read_reg(adap, A_CIM_QUEUE_CONFIG_CTRL);
	addr = G_CIMQBASE(v) * 64;    
	nwords = G_CIMQSIZE(v) * 64;  
	if (n > nwords)
		n = nwords;
	for (i = 0; i < n; i++, addr++) {
		t4_write_reg(adap, A_CIM_OBQ_DBG_CFG, V_OBQDBGADDR(addr) |
			     F_OBQDBGEN);
		err = t4_wait_op_done(adap, A_CIM_OBQ_DBG_CFG, F_OBQDBGBUSY, 0,
				      2, 1);
		if (err)
			return err;
		*data++ = t4_read_reg(adap, A_CIM_OBQ_DBG_DATA);
	}
	t4_write_reg(adap, A_CIM_OBQ_DBG_CFG, 0);
	return i;
}
int t4_read_cim_obq ( struct adapter * adap , unsigned int qid , u32 * data , size_t n ) { int i , err ; unsigned int addr , v , nwords ; int cim_num_obq = adap -> chip_params -> cim_num_obq ; if ( ( qid > ( cim_num_obq - 1 ) ) || ( n & 3 ) ) return - EINVAL ; t4_write_reg ( adap , A_CIM_QUEUE_CONFIG_REF , F_OBQSELECT | V_QUENUMSELECT ( qid ) ) ; v = t4_read_reg ( adap , A_CIM_QUEUE_CONFIG_CTRL ) ; addr = G_CIMQBASE ( v ) * 64 ; nwords = G_CIMQSIZE ( v ) * 64 ; if ( n > nwords ) n = nwords ; for ( i = 0 ; i < n ; i ++ , addr ++ ) { t4_write_reg ( adap , A_CIM_OBQ_DBG_CFG , V_OBQDBGADDR ( addr ) | F_OBQDBGEN ) ; err = t4_wait_op_done ( adap , A_CIM_OBQ_DBG_CFG , F_OBQDBGBUSY , 0 , 2 , 1 ) ; if ( err ) return err ; * data ++ = t4_read_reg ( adap , A_CIM_OBQ_DBG_DATA ) ; } t4_write_reg ( adap , A_CIM_OBQ_DBG_CFG , 0 ) ; return i ; }
t4_read_cim_obq - read the contents of a CIM outbound queue
      @adap: the adapter
      @qid: the queue index
      @data: where to store the queue contents
      @n: capacity of @data in 32-bit words
t4_read_cim_obq - read the contents of a CIM outbound queue @adap : the adapter @qid : the queue index @data : where to store the queue contents @n : capacity of @data in 32 - bit words
/* muliple of 256 -> muliple of 4 */ /* same */