__be32 doorbell[2];  
int mthca_tavor_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,			     struct ib_recv_wr **bad_wr){	struct mthca_dev *dev = to_mdev(ibqp->device);	struct mthca_qp *qp = to_mqp(ibqp);	unsigned long flags;	int err = 0;	int nreq;	int i;	int size;	int size0 = 0;	int ind;	void *wqe;	void *prev_wqe;	spin_lock_irqsave(&qp->rq.lock, flags);	/* XXX check that state is OK to post receive */	ind = qp->rq.next_ind;	for (nreq = 0; wr; ++nreq, wr = wr->next) {		if (mthca_wq_overflow(&qp->rq, nreq, qp->ibqp.recv_cq)) {			mthca_err(dev, "RQ %06x full (%u head, %u tail,"					" %d max, %d nreq)\n", qp->qpn,					qp->rq.head, qp->rq.tail,					qp->rq.max, nreq);			err = -ENOMEM;			*bad_wr = wr;			goto out;		}		wqe = get_recv_wqe(qp, ind);		prev_wqe = qp->rq.last;		qp->rq.last = wqe;		((struct mthca_next_seg *) wqe)->nda_op = 0;		((struct mthca_next_seg *) wqe)->ee_nds =			cpu_to_be32(MTHCA_NEXT_DBD);		((struct mthca_next_seg *) wqe)->flags = 0;		wqe += sizeof (struct mthca_next_seg);		size = sizeof (struct mthca_next_seg) / 16;		if (unlikely(wr->num_sge > qp->rq.max_gs)) {			err = -EINVAL;			*bad_wr = wr;			goto out;		}		for (i = 0; i < wr->num_sge; ++i) {			((struct mthca_data_seg *) wqe)->byte_count =				cpu_to_be32(wr->sg_list[i].length);			((struct mthca_data_seg *) wqe)->lkey =				cpu_to_be32(wr->sg_list[i].lkey);			((struct mthca_data_seg *) wqe)->addr =				cpu_to_be64(wr->sg_list[i].addr);			wqe += sizeof (struct mthca_data_seg);			size += sizeof (struct mthca_data_seg) / 16;		}		qp->wrid[ind] = wr->wr_id;		((struct mthca_next_seg *) prev_wqe)->nda_op =			cpu_to_be32((ind << qp->rq.wqe_shift) | 1);		wmb();		((struct mthca_next_seg *) prev_wqe)->ee_nds =			cpu_to_be32(MTHCA_NEXT_DBD | size);		if (!size0)			size0 = size;		++ind;		if (unlikely(ind >= qp->rq.max))			ind -= qp->rq.max;	}out:	if (likely(nreq)) {		__be32 doorbell[2];		doorbell[0] = cpu_to_be32((qp->rq.next_ind << qp->rq.wqe_shift) | size0);		doorbell[1] = cpu_to_be32((qp->qpn << 8) | nreq);		wmb();		mthca_write64(doorbell,			      dev->kar + MTHCA_RECEIVE_DOORBELL,			      MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));	}	qp->rq.next_ind = ind;	qp->rq.head    += nreq;	spin_unlock_irqrestore(&qp->rq.lock, flags);	return err;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/ae57e24a4006fd46b73d842ee99db9580ef74a02/mthca_qp.c/clean/drivers/infiniband/hw/mthca/mthca_qp.c