FreeBSD/sys/dev/cxgb/common/cxgb_t3_hw.c
/**
 *	t3_sge_init_flcntxt - initialize an SGE free-buffer list context
 *	@adapter: the adapter to configure
 *	@id: the context id
 *	@gts_enable: whether to enable GTS for the context
 *	@base_addr: base address of queue
 *	@size: number of queue entries
 *	@bsize: size of each buffer for this queue
 *	@cong_thres: threshold to signal congestion to upstream producers
 *	@gen: initial generation value for the context
 *	@cidx: consumer pointer
 *
 *	Initialize an SGE free list context and make it ready for use.  The
 *	caller is responsible for ensuring only one context operation occurs
 *	at a time.
 */


Initialize an SGE free list context and make it ready for use.  The
caller is responsible for ensuring only one context operation occurs
at a time.
Initialize an SGE free list 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_flcntxt(adapter_t *adapter, unsigned int id, int gts_enable,
			u64 base_addr, unsigned int size, unsigned int bsize,
			unsigned int cong_thres, int gen, unsigned int cidx)
{
	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, (u32)base_addr);
	base_addr >>= 32;
	t3_write_reg(adapter, A_SG_CONTEXT_DATA1,
		     V_FL_BASE_HI((u32)base_addr) |
		     V_FL_INDEX_LO(cidx & M_FL_INDEX_LO));
	t3_write_reg(adapter, A_SG_CONTEXT_DATA2, V_FL_SIZE(size) |
		     V_FL_GEN(gen) | V_FL_INDEX_HI(cidx >> 12) |
		     V_FL_ENTRY_SIZE_LO(bsize & M_FL_ENTRY_SIZE_LO));
	t3_write_reg(adapter, A_SG_CONTEXT_DATA3,
		     V_FL_ENTRY_SIZE_HI(bsize >> (32 - S_FL_ENTRY_SIZE_LO)) |
		     V_FL_CONG_THRES(cong_thres) | V_FL_GTS(gts_enable));
	return t3_sge_write_context(adapter, id, F_FREELIST);
}
int t3_sge_init_flcntxt ( adapter_t * adapter , unsigned int id , int gts_enable , u64 base_addr , unsigned int size , unsigned int bsize , unsigned int cong_thres , int gen , unsigned int cidx ) { 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 , ( u32 ) base_addr ) ; base_addr >>= 32 ; t3_write_reg ( adapter , A_SG_CONTEXT_DATA1 , V_FL_BASE_HI ( ( u32 ) base_addr ) | V_FL_INDEX_LO ( cidx & M_FL_INDEX_LO ) ) ; t3_write_reg ( adapter , A_SG_CONTEXT_DATA2 , V_FL_SIZE ( size ) | V_FL_GEN ( gen ) | V_FL_INDEX_HI ( cidx >> 12 ) | V_FL_ENTRY_SIZE_LO ( bsize & M_FL_ENTRY_SIZE_LO ) ) ; t3_write_reg ( adapter , A_SG_CONTEXT_DATA3 , V_FL_ENTRY_SIZE_HI ( bsize >> ( 32 - S_FL_ENTRY_SIZE_LO ) ) | V_FL_CONG_THRES ( cong_thres ) | V_FL_GTS ( gts_enable ) ) ; return t3_sge_write_context ( adapter , id , F_FREELIST ) ; }
t3_sge_init_flcntxt - initialize an SGE free-buffer list context
      @adapter: the adapter to configure
      @id: the context id
      @gts_enable: whether to enable GTS for the context
      @base_addr: base address of queue
      @size: number of queue entries
      @bsize: size of each buffer for this queue
      @cong_thres: threshold to signal congestion to upstream producers
      @gen: initial generation value for the context
      @cidx: consumer pointer
t3_sge_init_flcntxt - initialize an SGE free - buffer list context @adapter : the adapter to configure @id : the context id @gts_enable : whether to enable GTS for the context @base_addr : base address of queue @size : number of queue entries @bsize : size of each buffer for this queue @cong_thres : threshold to signal congestion to upstream producers @gen : initial generation value for the context @cidx : consumer pointer
/* must be 4K aligned */