[openib-general] [PATCH] CMA / local SA: make local SA module optional for CMA operations

Sean Hefty sean.hefty at intel.com
Thu Feb 2 14:34:01 PST 2006


Permit loading the CMA module without the local SA module.  Symbols from
the local SA are exported dynamically, and acquired by the CMA on CMA
module load.

This also provides an optimization to avoid checking the cache when it is
disabled, but the module is loaded.  This will become more important when
multicast tracking is added to the local SA module.

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

---

I'm not sure if this is an appropriate way of doing this, but it worked in
my testing.


Index: core/local_sa.c
===================================================================
--- core/local_sa.c	(revision 5278)
+++ core/local_sa.c	(working copy)
@@ -353,7 +353,6 @@ unlock:
 	mutex_unlock(&lock);
 	return ret;
 }
-EXPORT_SYMBOL(ib_get_path_rec);
 
 static void sa_db_free_data(void *context, void *data)
 {
@@ -446,6 +445,9 @@ static void sa_db_remove_one(struct ib_d
 static int __init sa_db_init(void)
 {
 	cache_timeout = msecs_to_jiffies(cache_timeout);
+	if (cache_timeout) {
+		EXPORT_SYMBOL(ib_get_path_rec);
+	}
 	hold_time = msecs_to_jiffies(hold_time);
 	update_delay = msecs_to_jiffies(update_delay);
 	return ib_register_client(&sa_db_client);
Index: core/cma.c
===================================================================
--- core/cma.c	(revision 5278)
+++ core/cma.c	(working copy)
@@ -63,6 +63,10 @@ static LIST_HEAD(dev_list);
 static LIST_HEAD(listen_any_list);
 static DEFINE_MUTEX(lock);
 
+static int (*cma_get_ib_path)(struct ib_device *device, u8 port_num,
+			      union ib_gid *sgid, union ib_gid *dgid,
+			      u16 pkey, struct ib_sa_path_rec *rec);
+
 struct cma_device {
 	struct list_head	list;
 	struct ib_device	*device;
@@ -1122,6 +1126,9 @@ static int cma_resolve_ib_route(struct r
 	struct cma_work *work;
 	int ret;
 
+	if (!cma_get_ib_path)
+		return cma_query_ib_route(id_priv, timeout_ms);
+
 	work = kzalloc(sizeof *work, GFP_KERNEL);
 	if (!work)
 		return -ENOMEM;
@@ -1132,7 +1139,7 @@ static int cma_resolve_ib_route(struct r
 		goto err1;
 	}
 
-	ret = ib_get_path_rec(id_priv->id.device, id_priv->id.port_num,
+	ret = cma_get_ib_path(id_priv->id.device, id_priv->id.port_num,
 			      ib_addr_get_sgid(addr), ib_addr_get_dgid(addr),
 			      ib_addr_get_pkey(addr), route->path_rec);
 	if (ret)
@@ -1697,12 +1704,20 @@ static void cma_remove_one(struct ib_dev
 
 static int cma_init(void)
 {
-	return ib_register_client(&cma_client);
+	int ret;
+
+	cma_get_ib_path = symbol_get(ib_get_path_rec);
+	ret = ib_register_client(&cma_client);
+	if (ret && cma_get_ib_path)
+		symbol_put(ib_get_path_rec);
+	return ret;
 }
 
 static void cma_cleanup(void)
 {
 	ib_unregister_client(&cma_client);
+	if (cma_get_ib_path)
+		symbol_put(ib_get_path_rec);
 }
 
 module_init(cma_init);






More information about the general mailing list