2 * Copyright (c) 2005-2006 Network Appliance, Inc. All rights reserved.
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the BSD-type
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
14 * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
17 * Redistributions in binary form must reproduce the above
18 * copyright notice, this list of conditions and the following
19 * disclaimer in the documentation and/or other materials provided
20 * with the distribution.
22 * Neither the name of the Network Appliance, Inc. nor the names of
23 * its contributors may be used to endorse or promote products
24 * derived from this software without specific prior written
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 * Author: Tom Tucker <tom@opengridcomputing.com>
41 #include <linux/module.h>
42 #include <linux/init.h>
44 #include <linux/sysctl.h>
45 #include <linux/sunrpc/clnt.h>
46 #include <linux/sunrpc/sched.h>
47 #include <linux/sunrpc/svc_rdma.h>
49 #define RPCDBG_FACILITY RPCDBG_SVCXPRT
51 /* RPC/RDMA parameters */
52 unsigned int svcrdma_ord
= RPCRDMA_ORD
;
53 static unsigned int min_ord
= 1;
54 static unsigned int max_ord
= 4096;
55 unsigned int svcrdma_max_requests
= RPCRDMA_MAX_REQUESTS
;
56 static unsigned int min_max_requests
= 4;
57 static unsigned int max_max_requests
= 16384;
58 unsigned int svcrdma_max_req_size
= RPCRDMA_MAX_REQ_SIZE
;
59 static unsigned int min_max_inline
= 4096;
60 static unsigned int max_max_inline
= 65536;
62 atomic_t rdma_stat_recv
;
63 atomic_t rdma_stat_read
;
64 atomic_t rdma_stat_write
;
65 atomic_t rdma_stat_sq_starve
;
66 atomic_t rdma_stat_rq_starve
;
67 atomic_t rdma_stat_rq_poll
;
68 atomic_t rdma_stat_rq_prod
;
69 atomic_t rdma_stat_sq_poll
;
70 atomic_t rdma_stat_sq_prod
;
73 * This function implements reading and resetting an atomic_t stat
74 * variable through read/write to a proc file. Any write to the file
75 * resets the associated statistic to zero. Any read returns it's
78 static int read_reset_stat(ctl_table
*table
, int write
,
79 struct file
*filp
, void __user
*buffer
, size_t *lenp
,
82 atomic_t
*stat
= (atomic_t
*)table
->data
;
92 int len
= snprintf(str_buf
, 32, "%d\n", atomic_read(stat
));
95 len
= strlen(str_buf
);
100 data
= &str_buf
[*ppos
];
104 if (len
&& copy_to_user(buffer
, str_buf
, len
))
112 static struct ctl_table_header
*svcrdma_table_header
;
113 static ctl_table svcrdma_parm_table
[] = {
115 .procname
= "max_requests",
116 .data
= &svcrdma_max_requests
,
117 .maxlen
= sizeof(unsigned int),
119 .proc_handler
= &proc_dointvec_minmax
,
120 .strategy
= &sysctl_intvec
,
121 .extra1
= &min_max_requests
,
122 .extra2
= &max_max_requests
125 .procname
= "max_req_size",
126 .data
= &svcrdma_max_req_size
,
127 .maxlen
= sizeof(unsigned int),
129 .proc_handler
= &proc_dointvec_minmax
,
130 .strategy
= &sysctl_intvec
,
131 .extra1
= &min_max_inline
,
132 .extra2
= &max_max_inline
135 .procname
= "max_outbound_read_requests",
136 .data
= &svcrdma_ord
,
137 .maxlen
= sizeof(unsigned int),
139 .proc_handler
= &proc_dointvec_minmax
,
140 .strategy
= &sysctl_intvec
,
146 .procname
= "rdma_stat_read",
147 .data
= &rdma_stat_read
,
148 .maxlen
= sizeof(atomic_t
),
150 .proc_handler
= &read_reset_stat
,
153 .procname
= "rdma_stat_recv",
154 .data
= &rdma_stat_recv
,
155 .maxlen
= sizeof(atomic_t
),
157 .proc_handler
= &read_reset_stat
,
160 .procname
= "rdma_stat_write",
161 .data
= &rdma_stat_write
,
162 .maxlen
= sizeof(atomic_t
),
164 .proc_handler
= &read_reset_stat
,
167 .procname
= "rdma_stat_sq_starve",
168 .data
= &rdma_stat_sq_starve
,
169 .maxlen
= sizeof(atomic_t
),
171 .proc_handler
= &read_reset_stat
,
174 .procname
= "rdma_stat_rq_starve",
175 .data
= &rdma_stat_rq_starve
,
176 .maxlen
= sizeof(atomic_t
),
178 .proc_handler
= &read_reset_stat
,
181 .procname
= "rdma_stat_rq_poll",
182 .data
= &rdma_stat_rq_poll
,
183 .maxlen
= sizeof(atomic_t
),
185 .proc_handler
= &read_reset_stat
,
188 .procname
= "rdma_stat_rq_prod",
189 .data
= &rdma_stat_rq_prod
,
190 .maxlen
= sizeof(atomic_t
),
192 .proc_handler
= &read_reset_stat
,
195 .procname
= "rdma_stat_sq_poll",
196 .data
= &rdma_stat_sq_poll
,
197 .maxlen
= sizeof(atomic_t
),
199 .proc_handler
= &read_reset_stat
,
202 .procname
= "rdma_stat_sq_prod",
203 .data
= &rdma_stat_sq_prod
,
204 .maxlen
= sizeof(atomic_t
),
206 .proc_handler
= &read_reset_stat
,
213 static ctl_table svcrdma_table
[] = {
215 .procname
= "svc_rdma",
217 .child
= svcrdma_parm_table
224 static ctl_table svcrdma_root_table
[] = {
226 .ctl_name
= CTL_SUNRPC
,
227 .procname
= "sunrpc",
229 .child
= svcrdma_table
236 void svc_rdma_cleanup(void)
238 dprintk("SVCRDMA Module Removed, deregister RPC RDMA transport\n");
239 if (svcrdma_table_header
) {
240 unregister_sysctl_table(svcrdma_table_header
);
241 svcrdma_table_header
= NULL
;
243 svc_unreg_xprt_class(&svc_rdma_class
);
246 int svc_rdma_init(void)
248 dprintk("SVCRDMA Module Init, register RPC RDMA transport\n");
249 dprintk("\tsvcrdma_ord : %d\n", svcrdma_ord
);
250 dprintk("\tmax_requests : %d\n", svcrdma_max_requests
);
251 dprintk("\tsq_depth : %d\n",
252 svcrdma_max_requests
* RPCRDMA_SQ_DEPTH_MULT
);
253 dprintk("\tmax_inline : %d\n", svcrdma_max_req_size
);
254 if (!svcrdma_table_header
)
255 svcrdma_table_header
=
256 register_sysctl_table(svcrdma_root_table
);
258 /* Register RDMA with the SVC transport switch */
259 svc_reg_xprt_class(&svc_rdma_class
);
262 MODULE_AUTHOR("Tom Tucker <tom@opengridcomputing.com>");
263 MODULE_DESCRIPTION("SVC RDMA Transport");
264 MODULE_LICENSE("Dual BSD/GPL");
265 module_init(svc_rdma_init
);
266 module_exit(svc_rdma_cleanup
);