aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Dreier <rolandd@cisco.com>2005-11-28 21:14:30 +0000
committerRoland Dreier <rolandd@cisco.com>2006-11-09 19:57:04 -0800
commit2967b2c2dee7a03862ee16276bd1df719ca7bdc5 (patch)
tree842ca4ddd2c1e7f58abe98b9f873478f154878cd
parent077b1a5af062a9e430d11c8dee425f88f053d377 (diff)
downloadlibmthca-2967b2c2dee7a03862ee16276bd1df719ca7bdc5.tar.gz
Reset QP's last pointers when transitioning to RESET state
Signed-off-by: Roland Dreier <rolandd@cisco.com>
-rw-r--r--ChangeLog6
-rw-r--r--src/mthca.h1
-rw-r--r--src/qp.c15
-rw-r--r--src/verbs.c16
4 files changed, 24 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index f888def..66299f3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2005-11-28 Roland Dreier <roland@cisco.com>
+
+ * src/qp.c (mthca_init_qp_indices): Set qp->sq.last and
+ qp->rq.last so that QP is fully reset when the indices are
+ reinited on transition to RESET state.
+
2005-11-09 Roland Dreier <roland@cisco.com>
* src/srq.c (mthca_tavor_post_srq_recv), src/qp.c
diff --git a/src/mthca.h b/src/mthca.h
index 486bcfd..152c0e7 100644
--- a/src/mthca.h
+++ b/src/mthca.h
@@ -310,6 +310,7 @@ extern struct ibv_qp *mthca_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr
extern int mthca_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
enum ibv_qp_attr_mask attr_mask);
extern int mthca_destroy_qp(struct ibv_qp *qp);
+extern void mthca_init_qp_indices(struct mthca_qp *qp);
extern int mthca_tavor_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr,
struct ibv_send_wr **bad_wr);
extern int mthca_tavor_post_recv(struct ibv_qp *ibqp, struct ibv_recv_wr *wr,
diff --git a/src/qp.c b/src/qp.c
index bfe1003..0cf006a 100644
--- a/src/qp.c
+++ b/src/qp.c
@@ -65,6 +65,21 @@ static void *get_send_wqe(struct mthca_qp *qp, int n)
return qp->buf + qp->send_wqe_offset + (n << qp->sq.wqe_shift);
}
+void mthca_init_qp_indices(struct mthca_qp *qp)
+{
+ qp->sq.next_ind = 0;
+ qp->sq.last_comp = qp->sq.max - 1;
+ qp->sq.head = 0;
+ qp->sq.tail = 0;
+ qp->sq.last = get_send_wqe(qp, qp->sq.max - 1);
+
+ qp->rq.next_ind = 0;
+ qp->rq.last_comp = qp->rq.max - 1;
+ qp->rq.head = 0;
+ qp->rq.tail = 0;
+ qp->rq.last = get_recv_wqe(qp, qp->rq.max - 1);
+}
+
static inline int wq_overflow(struct mthca_wq *wq, int nreq, struct mthca_cq *cq)
{
unsigned cur;
diff --git a/src/verbs.c b/src/verbs.c
index 1dba4f2..191062d 100644
--- a/src/verbs.c
+++ b/src/verbs.c
@@ -394,19 +394,6 @@ int mthca_destroy_srq(struct ibv_srq *srq)
return 0;
}
-static void mthca_init_qp_indices(struct mthca_qp *qp)
-{
- qp->sq.next_ind = 0;
- qp->sq.last_comp = qp->sq.max - 1;
- qp->sq.head = 0;
- qp->sq.tail = 0;
-
- qp->rq.next_ind = 0;
- qp->rq.last_comp = qp->rq.max - 1;
- qp->rq.head = 0;
- qp->rq.tail = 0;
-}
-
struct ibv_qp *mthca_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *attr)
{
struct mthca_create_qp cmd;
@@ -427,11 +414,12 @@ struct ibv_qp *mthca_create_qp(struct ibv_pd *pd, struct ibv_qp_init_attr *attr)
qp->sq.max = align_queue_size(pd->context, attr->cap.max_send_wr, 0);
qp->rq.max = align_queue_size(pd->context, attr->cap.max_recv_wr, 0);
- mthca_init_qp_indices(qp);
if (mthca_alloc_qp_buf(pd, &attr->cap, attr->qp_type, qp))
goto err;
+ mthca_init_qp_indices(qp);
+
if (pthread_spin_init(&qp->sq.lock, PTHREAD_PROCESS_PRIVATE) ||
pthread_spin_init(&qp->rq.lock, PTHREAD_PROCESS_PRIVATE))
goto err_free;