FreeBSD/sys/dev/cxgb/common/cxgb_t3_hw.c
/**
 *	t3_sge_init_rspcntxt - initialize an SGE response queue context
 *	@adapter: the adapter to configure
 *	@id: the context id
 *	@irq_vec_idx: MSI-X interrupt vector index, 0 if no MSI-X, -1 if no IRQ
 *	@base_addr: base address of queue
 *	@size: number of queue entries
 *	@fl_thres: threshold for selecting the normal or jumbo free list
 *	@gen: initial generation value for the context
 *	@cidx: consumer pointer
 *
 *	Initialize an SGE response queue context and make it ready for use.
 *	The caller is responsible for ensuring only one context operation
 *	occurs at a time.
 */


Initialize an SGE response queue context and make it ready for use.
The caller is responsible for ensuring only one context operation
occurs at a time.
Initialize an SGE response queue context and make it ready for use . The caller is responsible for ensuring only one context operation occurs at a time .
int t3_sge_init_rspcntxt(adapter_t *adapter, unsigned int id, int irq_vec_idx,
			 u64 base_addr, unsigned int size,
			 unsigned int fl_thres, int gen, unsigned int cidx)
{
	unsigned int ctrl, intr = 0;
	if (base_addr & 0xfff)     
		return -EINVAL;
	if (t3_read_reg(adapter, A_SG_CONTEXT_CMD) & F_CONTEXT_CMD_BUSY)
		return -EBUSY;
	base_addr >>= 12;
	t3_write_reg(adapter, A_SG_CONTEXT_DATA0, V_CQ_SIZE(size) |
		     V_CQ_INDEX(cidx));
	t3_write_reg(adapter, A_SG_CONTEXT_DATA1, (u32)base_addr);
	base_addr >>= 32;
        ctrl = t3_read_reg(adapter, A_SG_CONTROL);
        if ((irq_vec_idx > 0) ||
		((irq_vec_idx == 0) && !(ctrl & F_ONEINTMULTQ)))
                	intr = F_RQ_INTR_EN;
        if (irq_vec_idx >= 0)
                intr |= V_RQ_MSI_VEC(irq_vec_idx);
	t3_write_reg(adapter, A_SG_CONTEXT_DATA2,
		     V_CQ_BASE_HI((u32)base_addr) | intr | V_RQ_GEN(gen));
	t3_write_reg(adapter, A_SG_CONTEXT_DATA3, fl_thres);
	return t3_sge_write_context(adapter, id, F_RESPONSEQ);
}
int t3_sge_init_rspcntxt ( adapter_t * adapter , unsigned int id , int irq_vec_idx , u64 base_addr , unsigned int size , unsigned int fl_thres , int gen , unsigned int cidx ) { unsigned int ctrl , intr = 0 ; if ( base_addr & 0xfff ) return - EINVAL ; if ( t3_read_reg ( adapter , A_SG_CONTEXT_CMD ) & F_CONTEXT_CMD_BUSY ) return - EBUSY ; base_addr >>= 12 ; t3_write_reg ( adapter , A_SG_CONTEXT_DATA0 , V_CQ_SIZE ( size ) | V_CQ_INDEX ( cidx ) ) ; t3_write_reg ( adapter , A_SG_CONTEXT_DATA1 , ( u32 ) base_addr ) ; base_addr >>= 32 ; ctrl = t3_read_reg ( adapter , A_SG_CONTROL ) ; if ( ( irq_vec_idx > 0 ) || ( ( irq_vec_idx == 0 ) && ! ( ctrl & F_ONEINTMULTQ ) ) ) intr = F_RQ_INTR_EN ; if ( irq_vec_idx >= 0 ) intr |= V_RQ_MSI_VEC ( irq_vec_idx ) ; t3_write_reg ( adapter , A_SG_CONTEXT_DATA2 , V_CQ_BASE_HI ( ( u32 ) base_addr ) | intr | V_RQ_GEN ( gen ) ) ; t3_write_reg ( adapter , A_SG_CONTEXT_DATA3 , fl_thres ) ; return t3_sge_write_context ( adapter , id , F_RESPONSEQ ) ; }
t3_sge_init_rspcntxt - initialize an SGE response queue context
      @adapter: the adapter to configure
      @id: the context id
      @irq_vec_idx: MSI-X interrupt vector index, 0 if no MSI-X, -1 if no IRQ
      @base_addr: base address of queue
      @size: number of queue entries
      @fl_thres: threshold for selecting the normal or jumbo free list
      @gen: initial generation value for the context
      @cidx: consumer pointer
t3_sge_init_rspcntxt - initialize an SGE response queue context @adapter : the adapter to configure @id : the context id @irq_vec_idx : MSI - X interrupt vector index 0 if no MSI - X - 1 if no IRQ @base_addr : base address of queue @size : number of queue entries @fl_thres : threshold for selecting the normal or jumbo free list @gen : initial generation value for the context @cidx : consumer pointer
/* must be 4K aligned */