wq->last_comp = wqe_index;  if (0) mthca_dbg(dev, "%s completion for QP %06x, index %d (nr %d)\n", is_send ? "Send" : "Receive", (*cur_qp)->qpn, wqe_index, wq->max); 
wq->last_comp = wqe_index; } 
static inline int mthca_poll_one(struct mthca_dev *dev,				 struct mthca_cq *cq,				 struct mthca_qp **cur_qp,				 int *freed,				 struct ib_wc *entry){	struct mthca_wq *wq;	struct mthca_cqe *cqe;	int wqe_index;	int is_error;	int is_send;	int free_cqe = 1;	int err = 0;	cqe = next_cqe_sw(cq);	if (!cqe)		return -EAGAIN;	/*	 * Make sure we read CQ entry contents after we've checked the	 * ownership bit.	 */	rmb();	if (0) {		mthca_dbg(dev, "%x/%d: CQE -> QPN %06x, WQE @ %08x\n",			  cq->cqn, cq->cons_index, be32_to_cpu(cqe->my_qpn),			  be32_to_cpu(cqe->wqe));		dump_cqe(dev, cqe);	}	is_error = (cqe->opcode & MTHCA_ERROR_CQE_OPCODE_MASK) ==		MTHCA_ERROR_CQE_OPCODE_MASK;	is_send  = is_error ? cqe->opcode & 0x01 : cqe->is_send & 0x80;	if (!*cur_qp || be32_to_cpu(cqe->my_qpn) != (*cur_qp)->qpn) {		/*		 * We do not have to take the QP table lock here,		 * because CQs will be locked while QPs are removed		 * from the table.		 */		*cur_qp = mthca_array_get(&dev->qp_table.qp,					  be32_to_cpu(cqe->my_qpn) &					  (dev->limits.num_qps - 1));		if (!*cur_qp) {			mthca_warn(dev, "CQ entry for unknown QP %06x\n",				   be32_to_cpu(cqe->my_qpn) & 0xffffff);			err = -EINVAL;			goto out;		}	}	entry->qp_num = (*cur_qp)->qpn;	if (is_send) {		wq = &(*cur_qp)->sq;		wqe_index = ((be32_to_cpu(cqe->wqe) - (*cur_qp)->send_wqe_offset)			     >> wq->wqe_shift);		entry->wr_id = (*cur_qp)->wrid[wqe_index +					       (*cur_qp)->rq.max];	} else {		wq = &(*cur_qp)->rq;		wqe_index = be32_to_cpu(cqe->wqe) >> wq->wqe_shift;		entry->wr_id = (*cur_qp)->wrid[wqe_index];	}	if (wq->last_comp < wqe_index)		wq->tail += wqe_index - wq->last_comp;	else		wq->tail += wqe_index + wq->max - wq->last_comp;	wq->last_comp = wqe_index;	if (0)		mthca_dbg(dev, "%s completion for QP %06x, index %d (nr %d)\n",			  is_send ? "Send" : "Receive",			  (*cur_qp)->qpn, wqe_index, wq->max);	if (is_error) {		err = handle_error_cqe(dev, cq, *cur_qp, wqe_index, is_send,				       (struct mthca_err_cqe *) cqe,				       entry, &free_cqe);		goto out;	}	if (is_send) {		entry->wc_flags = 0;		switch (cqe->opcode) {		case MTHCA_OPCODE_RDMA_WRITE:			entry->opcode    = IB_WC_RDMA_WRITE;			break;		case MTHCA_OPCODE_RDMA_WRITE_IMM:			entry->opcode    = IB_WC_RDMA_WRITE;			entry->wc_flags |= IB_WC_WITH_IMM;			break;		case MTHCA_OPCODE_SEND:			entry->opcode    = IB_WC_SEND;			break;		case MTHCA_OPCODE_SEND_IMM:			entry->opcode    = IB_WC_SEND;			entry->wc_flags |= IB_WC_WITH_IMM;			break;		case MTHCA_OPCODE_RDMA_READ:			entry->opcode    = IB_WC_RDMA_READ;			entry->byte_len  = be32_to_cpu(cqe->byte_cnt);			break;		case MTHCA_OPCODE_ATOMIC_CS:			entry->opcode    = IB_WC_COMP_SWAP;			entry->byte_len  = be32_to_cpu(cqe->byte_cnt);			break;		case MTHCA_OPCODE_ATOMIC_FA:			entry->opcode    = IB_WC_FETCH_ADD;			entry->byte_len  = be32_to_cpu(cqe->byte_cnt);			break;		case MTHCA_OPCODE_BIND_MW:			entry->opcode    = IB_WC_BIND_MW;			break;		default:			entry->opcode    = MTHCA_OPCODE_INVALID;			break;		}	} else {		entry->byte_len = be32_to_cpu(cqe->byte_cnt);		switch (cqe->opcode & 0x1f) {		case IB_OPCODE_SEND_LAST_WITH_IMMEDIATE:		case IB_OPCODE_SEND_ONLY_WITH_IMMEDIATE:			entry->wc_flags = IB_WC_WITH_IMM;			entry->imm_data = cqe->imm_etype_pkey_eec;			entry->opcode = IB_WC_RECV;			break;		case IB_OPCODE_RDMA_WRITE_LAST_WITH_IMMEDIATE:		case IB_OPCODE_RDMA_WRITE_ONLY_WITH_IMMEDIATE:			entry->wc_flags = IB_WC_WITH_IMM;			entry->imm_data = cqe->imm_etype_pkey_eec;			entry->opcode = IB_WC_RECV_RDMA_WITH_IMM;			break;		default:			entry->wc_flags = 0;			entry->opcode = IB_WC_RECV;			break;		}		entry->slid 	   = be16_to_cpu(cqe->rlid);		entry->sl   	   = be16_to_cpu(cqe->sl_g_mlpath) >> 12;		entry->src_qp 	   = be32_to_cpu(cqe->rqpn) & 0xffffff;		entry->dlid_path_bits = be16_to_cpu(cqe->sl_g_mlpath) & 0x7f;		entry->pkey_index  = be32_to_cpu(cqe->imm_etype_pkey_eec) >> 16;		entry->wc_flags   |= be16_to_cpu(cqe->sl_g_mlpath) & 0x80 ?					IB_WC_GRH : 0;	}	entry->status = IB_WC_SUCCESS; out:	if (likely(free_cqe)) {		set_cqe_hw(cqe);		++(*freed);		++cq->cons_index;	}	return err;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/ec34a922d243c3401a694450734e9effb2bafbfe/mthca_cq.c/clean/drivers/infiniband/hw/mthca/mthca_cq.c