[openib-general] [PATCH] [AT] Initial changes to work with user AT

Hal Rosenstock halr at voltaire.com
Thu Jun 16 08:35:20 PDT 2005


Initial changes to work with user AT.
Also, some other changes based on code inspection.

Signed-off-by: Hal Rosenstock <halr at voltaire.com>

Index: at.c
===================================================================
--- at.c	(revision 2610)
+++ at.c	(working copy)
@@ -118,7 +118,7 @@
 	int sa_id;
 };
 
-struct async pending_reqs;	/* dummy head for cyclic list */
+static struct async pending_reqs;	/* dummy head for cyclic list */
 
 struct ib_at_src {
 	u32 ip;
@@ -286,7 +286,7 @@
 
 	spin_lock_irqsave(&pending_reqs.lock, flags);
 	new_id = ++req_id;
-	if (!new_id)
+	if (!new_id)		/* 0 is not used as req_id (reserved value) */
 		new_id = ++req_id;
 	spin_unlock_irqrestore(&pending_reqs.lock, flags);
 
@@ -319,9 +319,13 @@
 		break;
 	default:
 		WARN("bad async req type %d", pend->type);
+		if (pend->sa_query) {
+			ib_sa_cancel_query(pend->sa_id, pend->sa_query);
+			pend->sa_query = NULL;
+		}
 		pend->status = IB_AT_STATUS_INVALID;
 		pend->type = IBAT_REQ_NONE;
-		pend->sa_query = NULL;
+		break;
 	}
 }
 
@@ -377,16 +381,16 @@
 
 	DEBUG("pend %p nrec %d async %p", pend, nrec, q);
 
+	if (pend->sa_query) {
+		ib_sa_cancel_query(pend->sa_id, pend->sa_query);
+		pend->sa_query = NULL;
+	}
+
 	if (pend->status != IB_AT_STATUS_PENDING)
 		WARN("pend %p already completed? status %d", pend, pend->status);
 
 	pend->status = nrec < 0 ? IB_AT_STATUS_ERROR : IB_AT_STATUS_COMPLETED;
 
-	if (pend->sa_query) {
-		ib_sa_cancel_query(pend->sa_id, pend->sa_query);
-		pend->sa_query = NULL;
-	}
-
 	if (q)
 		spin_lock_irqsave(&q->lock, flags);
 
@@ -464,9 +468,12 @@
 
 	DEBUG("free async %p req %p", async, req);
 
+	if (req->pend.sa_query) {
+		ib_sa_cancel_query(req->pend.sa_id, req->pend.sa_query);
+		req->pend.sa_query = NULL;
+	}
 	req->pend.status = IB_AT_STATUS_INVALID;
 	req->pend.type = IBAT_REQ_NONE;
-	req->pend.sa_query = NULL;
 
 	kmem_cache_free(route_req_cache, req);
 }
@@ -477,9 +484,12 @@
 
 	DEBUG("free async %p req %p", async, req);
 
+	if (req->pend.sa_query) {
+		ib_sa_cancel_query(req->pend.sa_id, req->pend.sa_query);
+		req->pend.sa_query = NULL;
+	}
 	req->pend.status = IB_AT_STATUS_INVALID;
 	req->pend.type = IBAT_REQ_NONE;
-	req->pend.sa_query = NULL;
 
 	kmem_cache_free(path_req_cache, req);
 }
@@ -494,7 +504,7 @@
 	DEBUG("lookup in q %p pending %p", q, new);
 	spin_lock_irqsave(&q->lock, flags);
 	for (a = q->next; a != q; a = a->next) {
-		DEBUG("%d %d", a->type, type);
+		DEBUG("req type %d %d", a->type, type);
 		if (a->type == type && same_fn(a, new))
 			break;
 	}
@@ -508,7 +518,7 @@
 	unsigned long flags;
 	struct async *a;
 
-	DEBUG("lookup in q %p id %llx", q, id);
+	DEBUG("lookup in q %p id 0x%llx", q, id);
 	spin_lock_irqsave(&q->lock, flags);
 	for (a = q->next; a != q; a = a->next)
 		if (a->id == id)
@@ -551,8 +561,7 @@
 {
 	int n = min(npath, nelem);
 
-	DEBUG("fill ib_sa_path_rec %p output %d records", out, n);
-
+	DEBUG("output ib_sa_path_rec %p %d records", out, n);
 	memcpy(out, resp, n * sizeof (struct ib_sa_path_rec));
 	return n;
 }
@@ -589,15 +598,15 @@
 
 	DEBUG("req %p status %d", req, status);
 
+	req->pend.sa_query = NULL;
+
 	if (req->pend.parent) {
 		WARN("for child req %p???", req);
 		return;
 	}
 
-	req->pend.sa_query = NULL;
-
 	if (status) {
-		DEBUG("status %d - check if should retry", status);
+		DEBUG("status %d - checking if should retry", status);
 		if (status == -ETIMEDOUT &&
 		    jiffies - req->pend.start < IB_AT_REQ_TIMEOUT)
 			resolve_path(req);
@@ -625,7 +634,7 @@
 	struct path_req *preq;
 	unsigned long flags;
 
-	DEBUG("start sweeping");
+	DEBUG("start sweep");
 
 	spin_lock_irqsave(&pending_reqs.lock, flags);
 	for (pend = pending_reqs.next; pend != &pending_reqs; pend = next) {
@@ -638,7 +647,7 @@
 
 			DEBUG("examining route req %p pend %p", req, pend);
 			if (jiffies > pend->start + IB_AT_REQ_TIMEOUT) {
-				DEBUG("req delete <%d.%d.%d.%d> <%lu:%lu>",
+				DEBUG("delete route <%d.%d.%d.%d> <%lu:%lu>",
 				     (req->dst_ip & 0x000000ff),
 				     (req->dst_ip & 0x0000ff00) >> 8,
 				     (req->dst_ip & 0x00ff0000) >> 16,
@@ -653,7 +662,7 @@
 
 			DEBUG("examining path req %p pend %p", preq, pend);
 			if (jiffies > pend->start + IB_AT_REQ_TIMEOUT) {
-				DEBUG("req delete path <%lu:%lu>",
+				DEBUG("delete path <%lu:%lu>",
 				      jiffies, pend->start);
 
 				req_end(pend, -ETIMEDOUT, NULL);
@@ -661,6 +670,7 @@
 			break;
 		default:
 			WARN("unknown async req type %d", pend->type);
+			break;
 		}
 	}
 
@@ -722,7 +732,8 @@
 					    &req->pend.sa_query);
 
 	if (req->pend.sa_id < 0) {
-		WARN("ib_sa_path_rec_get %d", req->pend.sa_id);
+		WARN("ib_sa_path_rec_get failed %d", req->pend.sa_id);
+		req->pend.sa_query = NULL;
 		return req->pend.sa_id;
 	}
 






More information about the general mailing list