Commit 7c37d744 authored by Ralph Campbell's avatar Ralph Campbell Committed by Roland Dreier

IB/ipath: Improve UD loopback performance by allocating temp array only once

Receive work queue entries are checked for L_Key validity, and
pointers to the memory region structure are saved in an allocated
structure.  For UD loopback packets, this structure is allocated and
freed for each packet.  This patch changes that to allocate/free
during QP creation and destruction.
Signed-off-by: default avatarRalph Campbell <ralph.campbell@qlogic.com>
Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
parent 64f22fa1
...@@ -745,6 +745,7 @@ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd, ...@@ -745,6 +745,7 @@ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd,
struct ipath_swqe *swq = NULL; struct ipath_swqe *swq = NULL;
struct ipath_ibdev *dev; struct ipath_ibdev *dev;
size_t sz; size_t sz;
size_t sg_list_sz;
struct ib_qp *ret; struct ib_qp *ret;
if (init_attr->create_flags) { if (init_attr->create_flags) {
...@@ -789,19 +790,31 @@ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd, ...@@ -789,19 +790,31 @@ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd,
goto bail; goto bail;
} }
sz = sizeof(*qp); sz = sizeof(*qp);
sg_list_sz = 0;
if (init_attr->srq) { if (init_attr->srq) {
struct ipath_srq *srq = to_isrq(init_attr->srq); struct ipath_srq *srq = to_isrq(init_attr->srq);
sz += sizeof(*qp->r_sg_list) * if (srq->rq.max_sge > 1)
srq->rq.max_sge; sg_list_sz = sizeof(*qp->r_sg_list) *
} else (srq->rq.max_sge - 1);
sz += sizeof(*qp->r_sg_list) * } else if (init_attr->cap.max_recv_sge > 1)
init_attr->cap.max_recv_sge; sg_list_sz = sizeof(*qp->r_sg_list) *
qp = kmalloc(sz, GFP_KERNEL); (init_attr->cap.max_recv_sge - 1);
qp = kmalloc(sz + sg_list_sz, GFP_KERNEL);
if (!qp) { if (!qp) {
ret = ERR_PTR(-ENOMEM); ret = ERR_PTR(-ENOMEM);
goto bail_swq; goto bail_swq;
} }
if (sg_list_sz && (init_attr->qp_type == IB_QPT_UD ||
init_attr->qp_type == IB_QPT_SMI ||
init_attr->qp_type == IB_QPT_GSI)) {
qp->r_ud_sg_list = kmalloc(sg_list_sz, GFP_KERNEL);
if (!qp->r_ud_sg_list) {
ret = ERR_PTR(-ENOMEM);
goto bail_qp;
}
} else
qp->r_ud_sg_list = NULL;
if (init_attr->srq) { if (init_attr->srq) {
sz = 0; sz = 0;
qp->r_rq.size = 0; qp->r_rq.size = 0;
...@@ -818,7 +831,7 @@ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd, ...@@ -818,7 +831,7 @@ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd,
qp->r_rq.size * sz); qp->r_rq.size * sz);
if (!qp->r_rq.wq) { if (!qp->r_rq.wq) {
ret = ERR_PTR(-ENOMEM); ret = ERR_PTR(-ENOMEM);
goto bail_qp; goto bail_sg_list;
} }
} }
...@@ -848,7 +861,7 @@ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd, ...@@ -848,7 +861,7 @@ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd,
if (err) { if (err) {
ret = ERR_PTR(err); ret = ERR_PTR(err);
vfree(qp->r_rq.wq); vfree(qp->r_rq.wq);
goto bail_qp; goto bail_sg_list;
} }
qp->ip = NULL; qp->ip = NULL;
qp->s_tx = NULL; qp->s_tx = NULL;
...@@ -925,6 +938,8 @@ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd, ...@@ -925,6 +938,8 @@ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd,
vfree(qp->r_rq.wq); vfree(qp->r_rq.wq);
ipath_free_qp(&dev->qp_table, qp); ipath_free_qp(&dev->qp_table, qp);
free_qpn(&dev->qp_table, qp->ibqp.qp_num); free_qpn(&dev->qp_table, qp->ibqp.qp_num);
bail_sg_list:
kfree(qp->r_ud_sg_list);
bail_qp: bail_qp:
kfree(qp); kfree(qp);
bail_swq: bail_swq:
...@@ -989,6 +1004,7 @@ int ipath_destroy_qp(struct ib_qp *ibqp) ...@@ -989,6 +1004,7 @@ int ipath_destroy_qp(struct ib_qp *ibqp)
kref_put(&qp->ip->ref, ipath_release_mmap_info); kref_put(&qp->ip->ref, ipath_release_mmap_info);
else else
vfree(qp->r_rq.wq); vfree(qp->r_rq.wq);
kfree(qp->r_ud_sg_list);
vfree(qp->s_wq); vfree(qp->s_wq);
kfree(qp); kfree(qp);
return 0; return 0;
......
...@@ -70,8 +70,6 @@ static void ipath_ud_loopback(struct ipath_qp *sqp, struct ipath_swqe *swqe) ...@@ -70,8 +70,6 @@ static void ipath_ud_loopback(struct ipath_qp *sqp, struct ipath_swqe *swqe)
goto done; goto done;
} }
rsge.sg_list = NULL;
/* /*
* Check that the qkey matches (except for QP0, see 9.6.1.4.1). * Check that the qkey matches (except for QP0, see 9.6.1.4.1).
* Qkeys with the high order bit set mean use the * Qkeys with the high order bit set mean use the
...@@ -115,21 +113,6 @@ static void ipath_ud_loopback(struct ipath_qp *sqp, struct ipath_swqe *swqe) ...@@ -115,21 +113,6 @@ static void ipath_ud_loopback(struct ipath_qp *sqp, struct ipath_swqe *swqe)
rq = &qp->r_rq; rq = &qp->r_rq;
} }
if (rq->max_sge > 1) {
/*
* XXX We could use GFP_KERNEL if ipath_do_send()
* was always called from the tasklet instead of
* from ipath_post_send().
*/
rsge.sg_list = kmalloc((rq->max_sge - 1) *
sizeof(struct ipath_sge),
GFP_ATOMIC);
if (!rsge.sg_list) {
dev->n_pkt_drops++;
goto drop;
}
}
/* /*
* Get the next work request entry to find where to put the data. * Get the next work request entry to find where to put the data.
* Note that it is safe to drop the lock after changing rq->tail * Note that it is safe to drop the lock after changing rq->tail
...@@ -147,6 +130,7 @@ static void ipath_ud_loopback(struct ipath_qp *sqp, struct ipath_swqe *swqe) ...@@ -147,6 +130,7 @@ static void ipath_ud_loopback(struct ipath_qp *sqp, struct ipath_swqe *swqe)
goto drop; goto drop;
} }
wqe = get_rwqe_ptr(rq, tail); wqe = get_rwqe_ptr(rq, tail);
rsge.sg_list = qp->r_ud_sg_list;
if (!ipath_init_sge(qp, wqe, &rlen, &rsge)) { if (!ipath_init_sge(qp, wqe, &rlen, &rsge)) {
spin_unlock_irqrestore(&rq->lock, flags); spin_unlock_irqrestore(&rq->lock, flags);
dev->n_pkt_drops++; dev->n_pkt_drops++;
...@@ -242,7 +226,6 @@ static void ipath_ud_loopback(struct ipath_qp *sqp, struct ipath_swqe *swqe) ...@@ -242,7 +226,6 @@ static void ipath_ud_loopback(struct ipath_qp *sqp, struct ipath_swqe *swqe)
ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc, ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc,
swqe->wr.send_flags & IB_SEND_SOLICITED); swqe->wr.send_flags & IB_SEND_SOLICITED);
drop: drop:
kfree(rsge.sg_list);
if (atomic_dec_and_test(&qp->refcount)) if (atomic_dec_and_test(&qp->refcount))
wake_up(&qp->wait); wake_up(&qp->wait);
done:; done:;
......
...@@ -431,6 +431,7 @@ struct ipath_qp { ...@@ -431,6 +431,7 @@ struct ipath_qp {
u32 s_lsn; /* limit sequence number (credit) */ u32 s_lsn; /* limit sequence number (credit) */
struct ipath_swqe *s_wq; /* send work queue */ struct ipath_swqe *s_wq; /* send work queue */
struct ipath_swqe *s_wqe; struct ipath_swqe *s_wqe;
struct ipath_sge *r_ud_sg_list;
struct ipath_rq r_rq; /* receive work queue */ struct ipath_rq r_rq; /* receive work queue */
struct ipath_sge r_sg_list[0]; /* verified SGEs */ struct ipath_sge r_sg_list[0]; /* verified SGEs */
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment