FreeBSD/sys/dev/cxgb/common/cxgb_t3_hw.c
/**
 *	t3_sge_cqcntxt_op - perform an operation on a completion queue context
 *	@adapter: the adapter
 *	@id: the context id
 *	@op: the operation to perform
 *	@credits: credits to return to the CQ
 *
 *	Perform the selected operation on an SGE completion queue context.
 *	The caller is responsible for ensuring only one context operation
 *	occurs at a time.
 *
 *	For most operations the function returns the current HW position in
 *	the completion queue.
 */
perform an operation on a completion queue context
@adapter: the adapter
@id: the context id
@op: the operation to perform
@credits: credits to return to the CQ

Perform the selected operation on an SGE completion queue context.
The caller is responsible for ensuring only one context operation
occurs at a time.

For most operations the function returns the current HW position in
the completion queue.
perform an operation on a completion queue context @adapter : the adapter @id : the context id @op : the operation to perform @credits : credits to return to the CQ Perform the selected operation on an SGE completion queue context . The caller is responsible for ensuring only one context operation occurs at a time . For most operations the function returns the current HW position in the completion queue .
int t3_sge_cqcntxt_op(adapter_t *adapter, unsigned int id, unsigned int op,
		      unsigned int credits)
{
	u32 val;
	if (t3_read_reg(adapter, A_SG_CONTEXT_CMD) & F_CONTEXT_CMD_BUSY)
		return -EBUSY;
	t3_write_reg(adapter, A_SG_CONTEXT_DATA0, credits << 16);
	t3_write_reg(adapter, A_SG_CONTEXT_CMD, V_CONTEXT_CMD_OPCODE(op) |
		     V_CONTEXT(id) | F_CQ);
	if (t3_wait_op_done_val(adapter, A_SG_CONTEXT_CMD, F_CONTEXT_CMD_BUSY,
				0, SG_CONTEXT_CMD_ATTEMPTS, 1, &val))
		return -EIO;
	if (op >= 2 && op < 7) {
		if (adapter->params.rev > 0)
			return G_CQ_INDEX(val);
		t3_write_reg(adapter, A_SG_CONTEXT_CMD,
			     V_CONTEXT_CMD_OPCODE(0) | F_CQ | V_CONTEXT(id));
		if (t3_wait_op_done(adapter, A_SG_CONTEXT_CMD,
				    F_CONTEXT_CMD_BUSY, 0,
				    SG_CONTEXT_CMD_ATTEMPTS, 1))
			return -EIO;
		return G_CQ_INDEX(t3_read_reg(adapter, A_SG_CONTEXT_DATA0));
	}
	return 0;
}
int t3_sge_cqcntxt_op ( adapter_t * adapter , unsigned int id , unsigned int op , unsigned int credits ) { u32 val ; if ( t3_read_reg ( adapter , A_SG_CONTEXT_CMD ) & F_CONTEXT_CMD_BUSY ) return - EBUSY ; t3_write_reg ( adapter , A_SG_CONTEXT_DATA0 , credits << 16 ) ; t3_write_reg ( adapter , A_SG_CONTEXT_CMD , V_CONTEXT_CMD_OPCODE ( op ) | V_CONTEXT ( id ) | F_CQ ) ; if ( t3_wait_op_done_val ( adapter , A_SG_CONTEXT_CMD , F_CONTEXT_CMD_BUSY , 0 , SG_CONTEXT_CMD_ATTEMPTS , 1 , & val ) ) return - EIO ; if ( op >= 2 && op < 7 ) { if ( adapter -> params . rev > 0 ) return G_CQ_INDEX ( val ) ; t3_write_reg ( adapter , A_SG_CONTEXT_CMD , V_CONTEXT_CMD_OPCODE ( 0 ) | F_CQ | V_CONTEXT ( id ) ) ; if ( t3_wait_op_done ( adapter , A_SG_CONTEXT_CMD , F_CONTEXT_CMD_BUSY , 0 , SG_CONTEXT_CMD_ATTEMPTS , 1 ) ) return - EIO ; return G_CQ_INDEX ( t3_read_reg ( adapter , A_SG_CONTEXT_DATA0 ) ) ; } return 0 ; }
t3_sge_cqcntxt_op - perform an operation on a completion queue context
      @adapter: the adapter
      @id: the context id
      @op: the operation to perform
      @credits: credits to return to the CQ
t3_sge_cqcntxt_op - perform an operation on a completion queue context @adapter : the adapter @id : the context id @op : the operation to perform @credits : credits to return to the CQ