[openib-general] [PATCH 1/9] kDAPL: convert the cr list to linux native

Tom Duffy Tom.Duffy at Sun.COM
Mon Jun 13 17:18:06 PDT 2005


Signed-off-by: Tom Duffy <tduffy at sun.com>

Index: linux-kernel-ll2/dat-provider/dapl_ia.c
===================================================================
--- linux-kernel-ll2/dat-provider/dapl_ia.c	(revision 2595)
+++ linux-kernel-ll2/dat-provider/dapl_ia.c	(working copy)
@@ -110,7 +110,7 @@ u32 dapl_ia_abrupt_close(struct dapl_ia 
 	struct dapl_pz *pz, *next_pz;
 	struct dapl_evd *evd, *next_evd;
 	struct dapl_sp *sp, *next_sp;	/* for PSP and RSP queues */
-	struct dapl_cr *cr, *next_cr;
+	struct dapl_cr *cr;
 	struct dapl_hca *hca;
 
 	/*
@@ -210,12 +210,7 @@ u32 dapl_ia_abrupt_close(struct dapl_ia 
 						    ia_list_entry);
 
 		/* Remove CR's from this PSP and clean them up */
-		cr = dapl_llist_is_empty(&sp->cr_list_head) ? NULL :
-		    dapl_llist_peek_head(&sp->cr_list_head);
-		while (cr != NULL) {
-			next_cr = dapl_llist_next_entry(
-						&sp->cr_list_head, 
-						&cr->common.ia_list_entry);
+		list_for_each_entry(cr, &sp->cr_list, list) {
 			/* Remove the CR from the queue & cleanup */
 			spin_lock_irqsave(&sp->common.lock,
 					  sp->common.flags);
@@ -224,7 +219,6 @@ u32 dapl_ia_abrupt_close(struct dapl_ia 
 					       sp->common.flags);
 
 			dapl_cr_free(cr);
-			cr = next_cr;
 		}
 
 		dat_status = dapl_psp_free((struct dat_sp *)sp);
Index: linux-kernel-ll2/dat-provider/dapl_sp.c
===================================================================
--- linux-kernel-ll2/dat-provider/dapl_sp.c	(revision 2595)
+++ linux-kernel-ll2/dat-provider/dapl_sp.c	(working copy)
@@ -57,17 +57,14 @@ struct dapl_sp *dapl_sp_alloc(struct dap
 	dapl_llist_init_entry(&sp->common.ia_list_entry);
 	spin_lock_init(&sp->common.lock);
 
-	/*
-	 * Initialize the Body (set to NULL above)
-	 */
-	dapl_llist_init_head(&sp->cr_list_head);
+	INIT_LIST_HEAD(&sp->cr_list);
 
 	return sp;
 }
 
 void dapl_sp_dealloc(struct dapl_sp *sp)
 {
-	dapl_os_assert(dapl_llist_is_empty(&sp->cr_list_head));
+	dapl_os_assert(list_empty(&sp->cr_list));
 
 	kfree(sp);
 }
@@ -75,8 +72,7 @@ void dapl_sp_dealloc(struct dapl_sp *sp)
 void dapl_sp_link_cr(struct dapl_sp *sp, struct dapl_cr *cr)
 {
 	spin_lock_irqsave(&sp->common.lock, sp->common.flags);
-	dapl_llist_add_tail(&sp->cr_list_head,
-			    &cr->common.ia_list_entry, cr);
+	list_add_tail(&cr->list, &sp->cr_list);
 	sp->cr_list_count++;
 	spin_unlock_irqrestore(&sp->common.lock, sp->common.flags);
 }
@@ -86,32 +82,23 @@ struct dapl_cr *dapl_sp_search_cr(struct
 {
 	struct dapl_cr *cr;
 
-	if (dapl_llist_is_empty(&sp->cr_list_head))
-		return NULL;
-
-	cr = (struct dapl_cr *)dapl_llist_peek_head(&sp->cr_list_head);
-
-	do {
+	list_for_each_entry(cr, &sp->cr_list, list)
 		if (cr->cm_ctx == cm_ctx)
 			return cr;
-		
-		cr = cr->common.ia_list_entry.flink->data;
-	} while ((void *)cr != (void *)sp->cr_list_head->data);
-
+	
 	return NULL;
 }
 
 void dapl_sp_remove_cr(struct dapl_sp *sp, struct dapl_cr *cr)
 {
-	if (dapl_llist_is_empty(&sp->cr_list_head)) {
+	if (list_empty(&sp->cr_list)) {
 		dapl_dbg_log(DAPL_DBG_TYPE_ERR,
 			     "***dapl_sp_remove_cr: removing from empty queue! sp %p\n",
 			     sp);
 		return;
 	}
 
-	dapl_llist_remove_entry(&sp->cr_list_head,
-				&cr->common.ia_list_entry);
+	list_del(&cr->list);
 	sp->cr_list_count--;
 }
 
Index: linux-kernel-ll2/dat-provider/dapl.h
===================================================================
--- linux-kernel-ll2/dat-provider/dapl.h	(revision 2595)
+++ linux-kernel-ll2/dat-provider/dapl.h	(working copy)
@@ -290,13 +290,14 @@ struct dapl_sp {
 	/* maintenance fields */
 	boolean_t listening;	/* PSP is registered & active */
 	struct ib_cm_id *cm_srvc_handle;	/* Used by CM */
-	struct dapl_llist_entry *cr_list_head;	/* CR pending queue */
+	struct list_head cr_list;	/* CR pending queue */
 	int cr_list_count;	/* count of CRs on queue */
 };
 
 struct dapl_cr {
 	struct dat_cr cr;
 	struct dapl_common common;
+	struct list_head list;
 	/* for convenience the data is kept as a struct dat_cr_param.
 	 * however, the "local_endpoint" field is always NULL
 	 * so this wastes a pointer. This is probably ok to




More information about the general mailing list