FreeBSD/sys/dev/cxgb/common/cxgb_t3_hw.c
/**
 *	t3_sge_init_ecntxt - initialize an SGE egress context
 *	@adapter: the adapter to configure
 *	@id: the context id
 *	@gts_enable: whether to enable GTS for the context
 *	@type: the egress context type
 *	@respq: associated response queue
 *	@base_addr: base address of queue
 *	@size: number of queue entries
 *	@token: uP token
 *	@gen: initial generation value for the context
 *	@cidx: consumer pointer
 *
 *	Initialize an SGE egress context and make it ready for use.  If the
 *	platform allows concurrent context operations, the caller is
 *	responsible for appropriate locking.
 */


Initialize an SGE egress context and make it ready for use.  If the
platform allows concurrent context operations, the caller is
responsible for appropriate locking.
Initialize an SGE egress context and make it ready for use . If the platform allows concurrent context operations the caller is responsible for appropriate locking .
int t3_sge_init_ecntxt(adapter_t *adapter, unsigned int id, int gts_enable,
		       enum sge_context_type type, int respq, u64 base_addr,
		       unsigned int size, unsigned int token, int gen,
		       unsigned int cidx)
{
	unsigned int credits = type == SGE_CNTXT_OFLD ? 0 : FW_WR_NUM;
	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_EC_INDEX(cidx) |
		     V_EC_CREDITS(credits) | V_EC_GTS(gts_enable));
	t3_write_reg(adapter, A_SG_CONTEXT_DATA1, V_EC_SIZE(size) |
		     V_EC_BASE_LO((u32)base_addr & 0xffff));
	base_addr >>= 16;
	t3_write_reg(adapter, A_SG_CONTEXT_DATA2, (u32)base_addr);
	base_addr >>= 32;
	t3_write_reg(adapter, A_SG_CONTEXT_DATA3,
		     V_EC_BASE_HI((u32)base_addr & 0xf) | V_EC_RESPQ(respq) |
		     V_EC_TYPE(type) | V_EC_GEN(gen) | V_EC_UP_TOKEN(token) |
		     F_EC_VALID);
	return t3_sge_write_context(adapter, id, F_EGRESS);
}
int t3_sge_init_ecntxt ( adapter_t * adapter , unsigned int id , int gts_enable , enum sge_context_type type , int respq , u64 base_addr , unsigned int size , unsigned int token , int gen , unsigned int cidx ) { unsigned int credits = type == SGE_CNTXT_OFLD ? 0 : FW_WR_NUM ; 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_EC_INDEX ( cidx ) | V_EC_CREDITS ( credits ) | V_EC_GTS ( gts_enable ) ) ; t3_write_reg ( adapter , A_SG_CONTEXT_DATA1 , V_EC_SIZE ( size ) | V_EC_BASE_LO ( ( u32 ) base_addr & 0xffff ) ) ; base_addr >>= 16 ; t3_write_reg ( adapter , A_SG_CONTEXT_DATA2 , ( u32 ) base_addr ) ; base_addr >>= 32 ; t3_write_reg ( adapter , A_SG_CONTEXT_DATA3 , V_EC_BASE_HI ( ( u32 ) base_addr & 0xf ) | V_EC_RESPQ ( respq ) | V_EC_TYPE ( type ) | V_EC_GEN ( gen ) | V_EC_UP_TOKEN ( token ) | F_EC_VALID ) ; return t3_sge_write_context ( adapter , id , F_EGRESS ) ; }
t3_sge_init_ecntxt - initialize an SGE egress context
      @adapter: the adapter to configure
      @id: the context id
      @gts_enable: whether to enable GTS for the context
      @type: the egress context type
      @respq: associated response queue
      @base_addr: base address of queue
      @size: number of queue entries
      @token: uP token
      @gen: initial generation value for the context
      @cidx: consumer pointer
t3_sge_init_ecntxt - initialize an SGE egress context @adapter : the adapter to configure @id : the context id @gts_enable : whether to enable GTS for the context @type : the egress context type @respq : associated response queue @base_addr : base address of queue @size : number of queue entries @token : uP token @gen : initial generation value for the context @cidx : consumer pointer
/* must be 4K aligned */