linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] rds: transport module should be auto loaded when transport is set
@ 2020-06-25 20:46 rao.shoaib
  2020-06-25 23:26 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: rao.shoaib @ 2020-06-25 20:46 UTC (permalink / raw)
  To: linux-rdma, netdev
  Cc: Rao Shoaib, davem, leon, ka-cheong.poon, haakon.bugge,
	somasundaram.krishnasamy

From: Rao Shoaib <rao.shoaib@oracle.com>

This enhancement auto loads transport module when the transport
is set via SO_RDS_TRANSPORT socket option.

Reviewed-by: Ka-Cheong Poon <ka-cheong.poon@oracle.com>
Reviewed-by: Håkon Bugge <haakon.bugge@oracle.com>
Signed-off-by: Rao Shoaib <rao.shoaib@oracle.com>
Signed-off-by: Somasundaram Krishnasamy <somasundaram.krishnasamy@oracle.com>
---
 include/uapi/linux/rds.h |  4 +++-
 net/rds/transport.c      | 26 +++++++++++++++++---------
 2 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/include/uapi/linux/rds.h b/include/uapi/linux/rds.h
index cba368e55863..c21edb966c19 100644
--- a/include/uapi/linux/rds.h
+++ b/include/uapi/linux/rds.h
@@ -64,10 +64,12 @@
 
 /* supported values for SO_RDS_TRANSPORT */
 #define	RDS_TRANS_IB	0
-#define	RDS_TRANS_IWARP	1
+#define	RDS_TRANS_GAP	1
 #define	RDS_TRANS_TCP	2
 #define RDS_TRANS_COUNT	3
 #define	RDS_TRANS_NONE	(~0)
+/* don't use RDS_TRANS_IWARP - it is deprecated */
+#define RDS_TRANS_IWARP RDS_TRANS_GAP
 
 /* IOCTLS commands for SOL_RDS */
 #define SIOCRDSSETTOS		(SIOCPROTOPRIVATE)
diff --git a/net/rds/transport.c b/net/rds/transport.c
index 46f709a4b577..f8001ec80867 100644
--- a/net/rds/transport.c
+++ b/net/rds/transport.c
@@ -38,6 +38,12 @@
 #include "rds.h"
 #include "loop.h"
 
+static char * const rds_trans_modules[] = {
+	[RDS_TRANS_IB] = "rds_rdma",
+	[RDS_TRANS_GAP] = NULL,
+	[RDS_TRANS_TCP] = "rds_tcp",
+};
+
 static struct rds_transport *transports[RDS_TRANS_COUNT];
 static DECLARE_RWSEM(rds_trans_sem);
 
@@ -110,18 +116,20 @@ struct rds_transport *rds_trans_get(int t_type)
 {
 	struct rds_transport *ret = NULL;
 	struct rds_transport *trans;
-	unsigned int i;
 
 	down_read(&rds_trans_sem);
-	for (i = 0; i < RDS_TRANS_COUNT; i++) {
-		trans = transports[i];
-
-		if (trans && trans->t_type == t_type &&
-		    (!trans->t_owner || try_module_get(trans->t_owner))) {
-			ret = trans;
-			break;
-		}
+	trans = transports[t_type];
+	if (!trans) {
+		up_read(&rds_trans_sem);
+		if (rds_trans_modules[t_type])
+			request_module(rds_trans_modules[t_type]);
+		down_read(&rds_trans_sem);
+		trans = transports[t_type];
 	}
+	if (trans && trans->t_type == t_type &&
+	    (!trans->t_owner || try_module_get(trans->t_owner)))
+		ret = trans;
+
 	up_read(&rds_trans_sem);
 
 	return ret;
-- 
2.16.6


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] rds: transport module should be auto loaded when transport is set
  2020-06-25 20:46 [PATCH v2] rds: transport module should be auto loaded when transport is set rao.shoaib
@ 2020-06-25 23:26 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2020-06-25 23:26 UTC (permalink / raw)
  To: rao.shoaib
  Cc: linux-rdma, netdev, leon, ka-cheong.poon, haakon.bugge,
	somasundaram.krishnasamy

From: rao.shoaib@oracle.com
Date: Thu, 25 Jun 2020 13:46:00 -0700

> From: Rao Shoaib <rao.shoaib@oracle.com>
> 
> This enhancement auto loads transport module when the transport
> is set via SO_RDS_TRANSPORT socket option.
> 
> Reviewed-by: Ka-Cheong Poon <ka-cheong.poon@oracle.com>
> Reviewed-by: Håkon Bugge <haakon.bugge@oracle.com>
> Signed-off-by: Rao Shoaib <rao.shoaib@oracle.com>
> Signed-off-by: Somasundaram Krishnasamy <somasundaram.krishnasamy@oracle.com>

Applied, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-06-25 23:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-25 20:46 [PATCH v2] rds: transport module should be auto loaded when transport is set rao.shoaib
2020-06-25 23:26 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).