[openib-general] [PATCH] [SDP] 6/5 per device communication identifiers

Sean Hefty sean.hefty at intel.com
Thu Sep 15 11:23:21 PDT 2005


I can't count.  (Actually I counted SRP and SDP together...)

Here's a patch to update SDP to per device cm_id's.

Signed-off-by: Sean Hefty <sean.hefty at intel.com>


Index: linux-kernel/infiniband/ulp/sdp/sdp_actv.c
===================================================================
--- linux-kernel/infiniband/ulp/sdp/sdp_actv.c	(revision 3450)
+++ linux-kernel/infiniband/ulp/sdp/sdp_actv.c	(working copy)
@@ -480,7 +480,7 @@ static void sdp_cm_path_complete(u64 id,
 	/* XXX set timeout to default value of 14 */
 	path->packet_life = 13;
 #endif
-	conn->cm_id = ib_create_cm_id(sdp_cm_event_handler,
+	conn->cm_id = ib_create_cm_id(ca, sdp_cm_event_handler,
 				      hashent_arg(conn->hashent));
 	if (!conn->cm_id) {
 		sdp_dbg_warn(conn, "Failed to create CM handle, %d",
Index: linux-kernel/infiniband/ulp/sdp/sdp_conn.c
===================================================================
--- linux-kernel/infiniband/ulp/sdp/sdp_conn.c	(revision 3450)
+++ linux-kernel/infiniband/ulp/sdp/sdp_conn.c	(working copy)
@@ -1742,7 +1742,7 @@ static void sdp_device_init_one(struct i
 	if (IS_ERR(hca->pd)) {
 		sdp_warn("Error <%ld> creating HCA <%s> protection domain.",
 			 PTR_ERR(hca->pd), device->name);
-		goto error;
+		goto err1;
 	}
 	/*
 	 * memory registration
@@ -1751,7 +1751,7 @@ static void sdp_device_init_one(struct i
 	if (IS_ERR(hca->mem_h)) {
 		sdp_warn("Error <%ld> registering HCA <%s> memory.",
 			 PTR_ERR(hca->mem_h), device->name);
-		goto error;
+		goto err2;
 	}
 
 	hca->l_key = hca->mem_h->lkey;
@@ -1788,7 +1788,7 @@ static void sdp_device_init_one(struct i
 				 device->name, port_count,
 				 device->phys_port_cnt);
 
-			goto error;
+			goto err3;
 		}
 
 		memset(port, 0, sizeof *port);
@@ -1804,15 +1804,32 @@ static void sdp_device_init_one(struct i
 			sdp_warn("Error <%d> getting GID for port <%s:%d:%d>",
 				 result, device->name,
 				 port->index, device->phys_port_cnt);
-			goto error;
+			goto err3;
 		}
 	}
 
+	hca->listen_id = ib_create_cm_id(device, sdp_cm_event_handler, hca);
+	if (IS_ERR(hca->listen_id)) {
+		sdp_warn("Error <%ld> creating listen ID on <%s>.",
+			 PTR_ERR(hca->listen_id), device->name);
+		goto err3;
+	}
+
+	result = ib_cm_listen(hca->listen_id,
+		              cpu_to_be64(SDP_MSG_SERVICE_ID_VALUE),
+			      cpu_to_be64(SDP_MSG_SERVICE_ID_MASK));
+	if (result) {
+		sdp_warn("Error <%d> listening for SDP connections", result);
+		goto err4;
+	}
+
 	ib_set_client_data(device, &sdp_client, hca);
 
 	return;
 
-error:
+err4:
+	ib_destroy_cm_id(hca->listen_id);
+err3:
 	list_for_each_entry_safe(port, tmp, &hca->port_list, list) {
 		list_del(&port->list);
 		kfree(port);
@@ -1820,13 +1837,10 @@ error:
 
 	if (!IS_ERR(hca->fmr_pool))
 		ib_destroy_fmr_pool(hca->fmr_pool);
-
-	if (!IS_ERR(hca->mem_h))
-		(void)ib_dereg_mr(hca->mem_h);
-
-	if (!IS_ERR(hca->pd))
-		(void)ib_dealloc_pd(hca->pd);
-
+	ib_dereg_mr(hca->mem_h);
+err2:
+	ib_dealloc_pd(hca->pd);
+err1:
 	kfree(hca);
 }
 
@@ -1845,6 +1859,8 @@ static void sdp_device_remove_one(struct
 		return;
 	}
 
+	ib_destroy_cm_id(hca->listen_id);
+
 	list_for_each_entry_safe(port, tmp, &hca->port_list, list) {
 		list_del(&port->list);
 		kfree(port);
@@ -1853,12 +1869,8 @@ static void sdp_device_remove_one(struct
 	if (!IS_ERR(hca->fmr_pool))
 		ib_destroy_fmr_pool(hca->fmr_pool);
 
-	if (!IS_ERR(hca->mem_h))
-		(void)ib_dereg_mr(hca->mem_h);
-
-	if (!IS_ERR(hca->pd))
-		(void)ib_dealloc_pd(hca->pd);
-
+	ib_dereg_mr(hca->mem_h);
+	ib_dealloc_pd(hca->pd);
 	kfree(hca);
 }
 
@@ -1945,33 +1957,9 @@ int sdp_conn_table_init(int proto_family
 		goto error_iocb;
 	}
 
-	/*
-	 * start listening
-	 */
-	dev_root_s.listen_id = ib_create_cm_id(sdp_cm_event_handler,
-					       (void *)SDP_DEV_SK_INVALID);
-	if (!dev_root_s.listen_id) {
-		sdp_warn("Failed to create listen connection identifier.");
-		result = -ENOMEM;
-		goto error_conn;
-	}
-
-	result = ib_cm_listen(dev_root_s.listen_id,
-		              cpu_to_be64(SDP_MSG_SERVICE_ID_VALUE),
-			      cpu_to_be64(SDP_MSG_SERVICE_ID_MASK));
-	if (result) {
-		sdp_warn("Error <%d> listening for SDP connections", result);
-		goto error_listen;
-
-	}
-
 	sdp_dbg_init("Started listening for SDP connection requests");
 
 	return 0;
-error_listen:
-	ib_destroy_cm_id(dev_root_s.listen_id);
-error_conn:
-	sdp_main_iocb_cleanup();
 error_iocb:
 	dev_root_s.sk_array--;
 	free_pages((unsigned long)dev_root_s.sk_array, dev_root_s.sk_ordr);
@@ -2010,8 +1998,4 @@ void sdp_conn_table_clear(void)
 	 * delete IOCB table
 	 */
 	sdp_main_iocb_cleanup();
-	/*
-	 * stop listening
-	 */
-	ib_destroy_cm_id(dev_root_s.listen_id);
 }
Index: linux-kernel/infiniband/ulp/sdp/sdp_pass.c
===================================================================
--- linux-kernel/infiniband/ulp/sdp/sdp_pass.c	(revision 3450)
+++ linux-kernel/infiniband/ulp/sdp/sdp_pass.c	(working copy)
@@ -449,7 +449,7 @@ int sdp_cm_req_handler(struct ib_cm_id *
 	 * associate connection with a hca/port, and allocate IB.
 	 */
 	result = sdp_conn_alloc_ib(conn,
-				   event->param.req_rcvd.device,
+				   cm_id->device,
 				   event->param.req_rcvd.port,
 				   event->param.req_rcvd.primary_path->pkey);
 	if (result < 0) {
Index: linux-kernel/infiniband/ulp/sdp/sdp_dev.h
===================================================================
--- linux-kernel/infiniband/ulp/sdp/sdp_dev.h	(revision 3450)
+++ linux-kernel/infiniband/ulp/sdp/sdp_dev.h	(working copy)
@@ -154,6 +154,7 @@ struct sdev_hca {
 	u32                   r_key;     /* remote key */
 	struct ib_fmr_pool   *fmr_pool;  /* fast memory for Zcopy */
 	struct list_head      port_list; /* ports on this HCA */
+	struct ib_cm_id	     *listen_id;
 };
 
 struct sdev_root {
@@ -187,10 +188,6 @@ struct sdev_root {
 	spinlock_t bind_lock;
 	spinlock_t sock_lock;
 	spinlock_t listen_lock;
-	/*
-	 * SDP wide listen
-	 */
-	struct ib_cm_id *listen_id;      /* listen handle */
 };
 
 #endif /* _SDP_DEV_H */






More information about the general mailing list