/* Allocate the next available QPN and put the QP into the hash table. The hash table holds a reference to the QP.  */
static int ipath_alloc_qpn(struct ipath_qp_table *qpt, struct ipath_qp *qp, enum ib_qp_type type)
/* Allocate the next available QPN and put the QP into the hash table. The hash table holds a reference to the QP.  */
static int ipath_alloc_qpn(struct ipath_qp_table *qpt, struct ipath_qp *qp, enum ib_qp_type type)
{
	unsigned long flags;
	int ret;
	ret = alloc_qpn(qpt, type);
	if (ret < 0)
		goto bail;
	qp->ibqp.qp_num = ret;
	spin_lock_irqsave(&qpt->lock, flags);
	ret %= qpt->max;
	qp->next = qpt->table[ret];
	qpt->table[ret] = qp;
	atomic_inc(&qp->refcount);
	spin_unlock_irqrestore(&qpt->lock, flags);
	ret = 0;
bail:
	return ret;
}