Linux NFS development
 help / color / mirror / Atom feed
From: Tom Tucker <tom@opengridcomputing.com>
To: nfs@lists.sourceforge.net
Cc: neilb@suse.de, bfields@fieldses.org, gnb@sgi.com
Subject: [RFC,PATCH 01/35] svc: Add an svc transport class
Date: Mon, 01 Oct 2007 14:27:31 -0500	[thread overview]
Message-ID: <20071001192730.3250.89167.stgit@dell3.ogc.int> (raw)
In-Reply-To: <20071001191426.3250.15371.stgit@dell3.ogc.int>


The transport class (svc_xprt_class) represents a type of transport, e.g. 
udp, tcp, rdma.  A transport class has a unique name and a set of transport 
operations kept in the svc_xprt_ops structure.

A transport class can be dynamically registered and unregisterd. The 
svc_xprt_class represents the module that implements the transport
type and keeps reference counts on the module to avoid unloading while
there are active users.

The endpoint (svc_xprt) is a generic, transport independent endpoint that can 
be used to send and receive data for an RPC service. It inherits it's 
operations from the transport class. 

A transport driver module registers and unregisters itself with svc sunrpc
by calling svc_reg_xprt_class, and svc_unreg_xprt_class respectively. 

Signed-off-by: Tom Tucker <tom@opengridcomputing.com>
---

 include/linux/sunrpc/debug.h    |    1 
 include/linux/sunrpc/svc_xprt.h |   31 +++++++++++++
 net/sunrpc/Makefile             |    3 +
 net/sunrpc/svc_xprt.c           |   94 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 128 insertions(+), 1 deletions(-)

diff --git a/include/linux/sunrpc/debug.h b/include/linux/sunrpc/debug.h
index 3912cf1..092fcfa 100644
--- a/include/linux/sunrpc/debug.h
+++ b/include/linux/sunrpc/debug.h
@@ -21,6 +21,7 @@ #define RPCDBG_BIND		0x0020
 #define RPCDBG_SCHED		0x0040
 #define RPCDBG_TRANS		0x0080
 #define RPCDBG_SVCSOCK		0x0100
+#define RPCDBG_SVCXPRT		0x0100
 #define RPCDBG_SVCDSP		0x0200
 #define RPCDBG_MISC		0x0400
 #define RPCDBG_CACHE		0x0800
diff --git a/include/linux/sunrpc/svc_xprt.h b/include/linux/sunrpc/svc_xprt.h
new file mode 100644
index 0000000..a9a3afe
--- /dev/null
+++ b/include/linux/sunrpc/svc_xprt.h
@@ -0,0 +1,31 @@
+/*
+ * linux/include/linux/sunrpc/svc_xprt.h
+ *
+ * RPC server transport I/O
+ */
+
+#ifndef SUNRPC_SVC_XPRT_H
+#define SUNRPC_SVC_XPRT_H
+
+#include <linux/sunrpc/svc.h>
+
+struct svc_xprt_ops {
+};
+
+struct svc_xprt_class {
+	const char		*xcl_name;
+	struct module		*xcl_owner;
+	struct svc_xprt_ops	*xcl_ops;
+	struct list_head	xcl_list;
+};
+
+struct svc_xprt {
+	struct svc_xprt_class	*xpt_class;
+	struct svc_xprt_ops	xpt_ops;
+};
+
+int	svc_reg_xprt_class(struct svc_xprt_class *);
+int	svc_unreg_xprt_class(struct svc_xprt_class *);
+void	svc_xprt_init(struct svc_xprt_class *, struct svc_xprt *);
+
+#endif /* SUNRPC_SVC_XPRT_H */
diff --git a/net/sunrpc/Makefile b/net/sunrpc/Makefile
index 8ebfc4d..e37aa99 100644
--- a/net/sunrpc/Makefile
+++ b/net/sunrpc/Makefile
@@ -10,6 +10,7 @@ sunrpc-y := clnt.o xprt.o socklib.o xprt
 	    auth.o auth_null.o auth_unix.o \
 	    svc.o svcsock.o svcauth.o svcauth_unix.o \
 	    rpcb_clnt.o timer.o xdr.o \
-	    sunrpc_syms.o cache.o rpc_pipe.o
+	    sunrpc_syms.o cache.o rpc_pipe.o \
+	    svc_xprt.o
 sunrpc-$(CONFIG_PROC_FS) += stats.o
 sunrpc-$(CONFIG_SYSCTL) += sysctl.o
diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
new file mode 100644
index 0000000..f838b57
--- /dev/null
+++ b/net/sunrpc/svc_xprt.c
@@ -0,0 +1,94 @@
+/*
+ * linux/net/sunrpc/svc_xprt.c
+ *
+ * Author: Tom Tucker <tom@opengridcomputing.com>
+ */
+
+#include <linux/sched.h>
+#include <linux/errno.h>
+#include <linux/fcntl.h>
+#include <linux/net.h>
+#include <linux/in.h>
+#include <linux/inet.h>
+#include <linux/udp.h>
+#include <linux/tcp.h>
+#include <linux/unistd.h>
+#include <linux/slab.h>
+#include <linux/netdevice.h>
+#include <linux/skbuff.h>
+#include <linux/file.h>
+#include <linux/freezer.h>
+#include <net/sock.h>
+#include <net/checksum.h>
+#include <net/ip.h>
+#include <net/ipv6.h>
+#include <net/tcp_states.h>
+#include <linux/uaccess.h>
+#include <asm/ioctls.h>
+
+#include <linux/sunrpc/types.h>
+#include <linux/sunrpc/clnt.h>
+#include <linux/sunrpc/xdr.h>
+#include <linux/sunrpc/svcsock.h>
+#include <linux/sunrpc/stats.h>
+#include <linux/sunrpc/svc_xprt.h>
+
+#define RPCDBG_FACILITY	RPCDBG_SVCXPRT
+
+/* List of registered transport classes */
+static spinlock_t svc_xprt_class_lock = SPIN_LOCK_UNLOCKED;
+static LIST_HEAD(svc_xprt_class_list);
+
+int svc_reg_xprt_class(struct svc_xprt_class *xcl)
+{
+	struct svc_xprt_class *cl;
+	int res = -EEXIST;
+
+	dprintk("svc: Adding svc transport class '%s'\n",
+		xcl->xcl_name);
+
+	INIT_LIST_HEAD(&xcl->xcl_list);
+	spin_lock(&svc_xprt_class_lock);
+	list_for_each_entry(cl, &svc_xprt_class_list, xcl_list) {
+		if (xcl == cl)
+			goto out;
+	}
+	list_add_tail(&xcl->xcl_list, &svc_xprt_class_list);
+	res = 0;
+out:
+	spin_unlock(&svc_xprt_class_lock);
+	return res;
+}
+EXPORT_SYMBOL_GPL(svc_reg_xprt_class);
+
+int svc_unreg_xprt_class(struct svc_xprt_class *xcl)
+{
+	struct svc_xprt_class *cl;
+	int res = 0;
+
+	dprintk("svc: Removing svc transport class '%s'\n", xcl->xcl_name);
+
+	spin_lock(&svc_xprt_class_lock);
+	list_for_each_entry(cl, &svc_xprt_class_list, xcl_list) {
+		if (xcl == cl) {
+			list_del_init(&cl->xcl_list);
+			goto out;
+		}
+	}
+	res = -ENOENT;
+ out:
+	spin_unlock(&svc_xprt_class_lock);
+	return res;
+}
+EXPORT_SYMBOL_GPL(svc_unreg_xprt_class);
+
+/*
+ * Called by transport drivers to initialize the transport independent
+ * portion of the transport instance.
+ */
+void svc_xprt_init(struct svc_xprt_class *xcl, struct svc_xprt *xpt)
+{
+	xpt->xpt_class = xcl;
+	xpt->xpt_ops = *xcl->xcl_ops;
+}
+EXPORT_SYMBOL_GPL(svc_xprt_init);

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
NFS maillist  -  NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs

  reply	other threads:[~2007-10-01 19:27 UTC|newest]

Thread overview: 103+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-01 19:14 [RFC,PATCH 00/35] SVC Transport Switch Tom Tucker
2007-10-01 19:27 ` Tom Tucker [this message]
2007-10-01 19:27 ` [RFC,PATCH 02/35] svc: Make svc_sock the tcp/udp transport Tom Tucker
2007-10-01 19:27 ` [RFC, PATCH 03/35] svc: Change the svc_sock in the rqstp structure to a transport Tom Tucker
2007-10-01 19:27 ` [RFC, PATCH 04/35] svc: Add a max payload value to the transport Tom Tucker
2007-10-02 14:54   ` Chuck Lever
2007-10-02 16:28     ` Tom Tucker
2007-10-03 11:09       ` Greg Banks
2007-10-03 14:26         ` Tom Tucker
2007-10-03 15:18           ` Chuck Lever
2007-10-04  1:10           ` Greg Banks
2007-10-01 19:27 ` [RFC, PATCH 05/35] svc: Move sk_sendto and sk_recvfrom to svc_xprt_class Tom Tucker
2007-10-02 15:04   ` Chuck Lever
2007-10-02 16:29     ` Tom Tucker
2007-10-02 16:57       ` Chuck Lever
2007-10-02 18:24         ` Tom Tucker
2007-10-02 18:30           ` Tom Tucker
2007-10-02 18:47             ` Chuck Lever
2007-10-02 19:55               ` Tom Tucker
2007-10-02 20:29                 ` Chuck Lever
2007-10-02 20:35                   ` Tom Tucker
2007-10-02 20:38                     ` Tom Tucker
2007-10-04  1:34                 ` Greg Banks
2007-10-04  1:21             ` Greg Banks
2007-10-03 11:13       ` Greg Banks
2007-10-01 19:27 ` [RFC, PATCH 06/35] svc: Add transport specific xpo_release function Tom Tucker
2007-10-02 15:18   ` Chuck Lever
2007-10-02 16:35     ` Tom Tucker
2007-10-04  1:48     ` Greg Banks
2007-10-01 19:27 ` [RFC,PATCH 07/35] svc: Add per-transport delete functions Tom Tucker
2007-10-01 19:27 ` [RFC,PATCH 08/35] svc: Add xpo_prep_reply_hdr Tom Tucker
2007-10-01 19:27 ` [RFC, PATCH 09/35] svc: Add a transport function that checks for write space Tom Tucker
2007-10-01 19:27 ` [RFC, PATCH 10/35] svc: Move close processing to a single place Tom Tucker
2007-10-01 19:27 ` [RFC,PATCH 11/35] svc: Add xpo_accept transport function Tom Tucker
2007-10-02 15:33   ` Chuck Lever
2007-10-02 16:41     ` Tom Tucker
2007-10-02 17:07       ` Chuck Lever
2007-10-02 18:28         ` Tom Tucker
2007-10-02 18:49           ` Chuck Lever
2007-10-04  1:54           ` Greg Banks
2007-10-01 19:27 ` [RFC, PATCH 12/35] svc: Add a generic transport svc_create_xprt function Tom Tucker
2007-10-02 15:39   ` Chuck Lever
2007-10-03 20:01     ` Tom Tucker
2007-10-03 20:04       ` Tom Tucker
2007-10-04  2:30     ` Greg Banks
2007-10-04 15:18       ` Chuck Lever
2007-10-01 19:27 ` [RFC, PATCH 13/35] svc: Change services to use new svc_create_xprt service Tom Tucker
2007-10-02 15:44   ` Chuck Lever
2007-10-02 16:45     ` Tom Tucker
2007-10-03 15:25       ` Chuck Lever
2007-10-03 16:23         ` Tom Tucker
2007-10-04  2:35     ` Greg Banks
2007-10-04 14:27       ` Tom Tucker
2007-10-09 17:09   ` J. Bruce Fields
2007-10-09 18:32     ` Tom Tucker
2007-10-09 19:49       ` J. Bruce Fields
2007-10-09 20:19       ` J. Bruce Fields
2007-10-01 19:28 ` [RFC,PATCH 14/35] svc: Change sk_inuse to a kref Tom Tucker
2007-10-03 11:12   ` Christoph Hellwig
2007-10-03 14:39     ` Tom Tucker
2007-10-03 14:45     ` J. Bruce Fields
2007-10-03 14:52       ` Christoph Hellwig
2007-10-03 15:11         ` J. Bruce Fields
2007-10-03 15:15           ` Christoph Hellwig
2007-10-08  3:52             ` Neil Brown
2007-10-03 15:13         ` Chuck Lever
2007-10-03 15:34           ` J. Bruce Fields
2007-10-04  2:51             ` Greg Banks
2007-10-01 19:28 ` [RFC, PATCH 15/35] svc: Move sk_flags to the svc_xprt structure Tom Tucker
2007-10-01 19:28 ` [RFC, PATCH 16/35] svc: Move sk_server and sk_pool to svc_xprt Tom Tucker
2007-10-01 19:28 ` [RFC,PATCH 17/35] svc: Make close transport independent Tom Tucker
2007-10-01 19:28 ` [RFC,PATCH 18/35] svc: Move sk_reserved to svc_xprt Tom Tucker
2007-10-01 19:28 ` [RFC, PATCH 19/35] svc: Make the enqueue service transport neutral and export it Tom Tucker
2007-10-01 19:28 ` [RFC,PATCH 20/35] svc: Make svc_send transport neutral Tom Tucker
2007-10-02 16:15   ` Chuck Lever
2007-10-02 16:46     ` Tom Tucker
2007-10-02 16:54       ` Chuck Lever
2007-10-04  2:59         ` Greg Banks
2007-10-01 19:28 ` [RFC, PATCH 21/35] svc: Change svc_sock_received to svc_xprt_received and export it Tom Tucker
2007-10-02 16:18   ` Chuck Lever
2007-10-01 19:28 ` [RFC,PATCH 22/35] svc: Remove sk_lastrecv Tom Tucker
2007-10-01 19:28 ` [RFC,PATCH 23/35] svc: Move the authinfo cache to svc_xprt Tom Tucker
2007-10-01 19:28 ` [RFC, PATCH 24/35] svc: Make deferral processing xprt independent Tom Tucker
2007-10-01 19:28 ` [RFC, PATCH 25/35] svc: Move the sockaddr information to svc_xprt Tom Tucker
2007-10-02 16:34   ` Chuck Lever
2007-10-02 16:50     ` Tom Tucker
2007-10-01 19:28 ` [RFC, PATCH 26/35] svc: Make svc_sock_release svc_xprt_release Tom Tucker
2007-10-01 19:28 ` [RFC,PATCH 27/35] svc: Make svc_recv transport neutral Tom Tucker
2007-10-02 16:36   ` Chuck Lever
2007-10-01 19:28 ` [RFC, PATCH 28/35] svc: Make svc_age_temp_sockets svc_age_temp_transports Tom Tucker
2007-10-01 19:28 ` [RFC, PATCH 29/35] svc: Move common create logic to common code Tom Tucker
2007-10-02 16:42   ` Chuck Lever
2007-10-02 16:51     ` Tom Tucker
2007-10-01 19:28 ` [RFC, PATCH 30/35] svc: Removing remaining references to rq_sock in rqstp Tom Tucker
2007-10-01 19:28 ` [RFC, PATCH 31/35] svc: Make svc_check_conn_limits xprt independent Tom Tucker
2007-10-01 19:28 ` [RFC, PATCH 32/35] svc: Move the xprt independent code to the svc_xprt.c file Tom Tucker
2007-10-01 19:28 ` [RFC, PATCH 33/35] svc: Add transport hdr size for defer/revisit Tom Tucker
2007-10-01 19:28 ` [RFC,PATCH 34/35] svc: Add /proc/sys/sunrpc/transport files Tom Tucker
2007-10-01 19:28 ` [RFC, PATCH 35/35] knfsd: Support adding transports by writing portlist file Tom Tucker
2007-10-02 15:25 ` [RFC,PATCH 00/35] SVC Transport Switch J. Bruce Fields
2007-10-02 16:18   ` Tom Tucker
2007-10-03 11:03 ` Greg Banks
2007-10-03 14:02   ` Tom Tucker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071001192730.3250.89167.stgit@dell3.ogc.int \
    --to=tom@opengridcomputing.com \
    --cc=bfields@fieldses.org \
    --cc=gnb@sgi.com \
    --cc=neilb@suse.de \
    --cc=nfs@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox