Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2005-2007 Network Appliance, Inc. All rights reserved. |
| 3 | * |
| 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 |
| 8 | * license below: |
| 9 | * |
| 10 | * Redistribution and use in source and binary forms, with or without |
| 11 | * modification, are permitted provided that the following conditions |
| 12 | * are met: |
| 13 | * |
| 14 | * Redistributions of source code must retain the above copyright |
| 15 | * notice, this list of conditions and the following disclaimer. |
| 16 | * |
| 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. |
| 21 | * |
| 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 |
| 25 | * permission. |
| 26 | * |
| 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. |
| 38 | * |
| 39 | * Author: Tom Tucker <tom@opengridcomputing.com> |
| 40 | */ |
| 41 | |
| 42 | #include <linux/sunrpc/svc_xprt.h> |
| 43 | #include <linux/sunrpc/debug.h> |
| 44 | #include <linux/sunrpc/rpc_rdma.h> |
Alexey Dobriyan | a6b7a40 | 2011-06-06 10:43:46 +0000 | [diff] [blame] | 45 | #include <linux/interrupt.h> |
Alexey Dobriyan | d43c36d | 2009-10-07 17:09:06 +0400 | [diff] [blame] | 46 | #include <linux/sched.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 47 | #include <linux/slab.h> |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 48 | #include <linux/spinlock.h> |
Tejun Heo | a25e758 | 2010-10-15 17:49:27 +0200 | [diff] [blame] | 49 | #include <linux/workqueue.h> |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 50 | #include <rdma/ib_verbs.h> |
| 51 | #include <rdma/rdma_cm.h> |
| 52 | #include <linux/sunrpc/svc_rdma.h> |
Paul Gortmaker | bc3b2d7 | 2011-07-15 11:47:34 -0400 | [diff] [blame] | 53 | #include <linux/export.h> |
Tom Tucker | cec56c8 | 2012-02-15 11:30:00 -0600 | [diff] [blame] | 54 | #include "xprt_rdma.h" |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 55 | |
| 56 | #define RPCDBG_FACILITY RPCDBG_SVCXPRT |
| 57 | |
| 58 | static struct svc_xprt *svc_rdma_create(struct svc_serv *serv, |
Pavel Emelyanov | 62832c0 | 2010-09-29 16:04:18 +0400 | [diff] [blame] | 59 | struct net *net, |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 60 | struct sockaddr *sa, int salen, |
| 61 | int flags); |
| 62 | static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt); |
| 63 | static void svc_rdma_release_rqst(struct svc_rqst *); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 64 | static void dto_tasklet_func(unsigned long data); |
| 65 | static void svc_rdma_detach(struct svc_xprt *xprt); |
| 66 | static void svc_rdma_free(struct svc_xprt *xprt); |
| 67 | static int svc_rdma_has_wspace(struct svc_xprt *xprt); |
| 68 | static void rq_cq_reap(struct svcxprt_rdma *xprt); |
| 69 | static void sq_cq_reap(struct svcxprt_rdma *xprt); |
| 70 | |
Roel Kluin | 5eaa65b | 2008-12-10 15:18:31 -0800 | [diff] [blame] | 71 | static DECLARE_TASKLET(dto_tasklet, dto_tasklet_func, 0UL); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 72 | static DEFINE_SPINLOCK(dto_lock); |
| 73 | static LIST_HEAD(dto_xprt_q); |
| 74 | |
| 75 | static struct svc_xprt_ops svc_rdma_ops = { |
| 76 | .xpo_create = svc_rdma_create, |
| 77 | .xpo_recvfrom = svc_rdma_recvfrom, |
| 78 | .xpo_sendto = svc_rdma_sendto, |
| 79 | .xpo_release_rqst = svc_rdma_release_rqst, |
| 80 | .xpo_detach = svc_rdma_detach, |
| 81 | .xpo_free = svc_rdma_free, |
| 82 | .xpo_prep_reply_hdr = svc_rdma_prep_reply_hdr, |
| 83 | .xpo_has_wspace = svc_rdma_has_wspace, |
| 84 | .xpo_accept = svc_rdma_accept, |
| 85 | }; |
| 86 | |
| 87 | struct svc_xprt_class svc_rdma_class = { |
| 88 | .xcl_name = "rdma", |
| 89 | .xcl_owner = THIS_MODULE, |
| 90 | .xcl_ops = &svc_rdma_ops, |
| 91 | .xcl_max_payload = RPCSVC_MAXPAYLOAD_TCP, |
| 92 | }; |
| 93 | |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 94 | struct svc_rdma_op_ctxt *svc_rdma_get_context(struct svcxprt_rdma *xprt) |
| 95 | { |
| 96 | struct svc_rdma_op_ctxt *ctxt; |
| 97 | |
| 98 | while (1) { |
Tom Tucker | 8948896 | 2008-05-28 15:14:02 -0500 | [diff] [blame] | 99 | ctxt = kmem_cache_alloc(svc_rdma_ctxt_cachep, GFP_KERNEL); |
| 100 | if (ctxt) |
| 101 | break; |
| 102 | schedule_timeout_uninterruptible(msecs_to_jiffies(500)); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 103 | } |
Tom Tucker | 8948896 | 2008-05-28 15:14:02 -0500 | [diff] [blame] | 104 | ctxt->xprt = xprt; |
| 105 | INIT_LIST_HEAD(&ctxt->dto_q); |
| 106 | ctxt->count = 0; |
Tom Tucker | 64be8608 | 2008-10-06 14:45:18 -0500 | [diff] [blame] | 107 | ctxt->frmr = NULL; |
Tom Tucker | 8948896 | 2008-05-28 15:14:02 -0500 | [diff] [blame] | 108 | atomic_inc(&xprt->sc_ctxt_used); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 109 | return ctxt; |
| 110 | } |
| 111 | |
Tom Tucker | 146b6df | 2008-08-12 15:12:10 -0500 | [diff] [blame] | 112 | void svc_rdma_unmap_dma(struct svc_rdma_op_ctxt *ctxt) |
Tom Tucker | e6ab914 | 2008-05-28 12:08:48 -0500 | [diff] [blame] | 113 | { |
| 114 | struct svcxprt_rdma *xprt = ctxt->xprt; |
| 115 | int i; |
| 116 | for (i = 0; i < ctxt->count && ctxt->sge[i].length; i++) { |
Tom Tucker | 64be8608 | 2008-10-06 14:45:18 -0500 | [diff] [blame] | 117 | /* |
| 118 | * Unmap the DMA addr in the SGE if the lkey matches |
| 119 | * the sc_dma_lkey, otherwise, ignore it since it is |
| 120 | * an FRMR lkey and will be unmapped later when the |
| 121 | * last WR that uses it completes. |
| 122 | */ |
| 123 | if (ctxt->sge[i].lkey == xprt->sc_dma_lkey) { |
| 124 | atomic_dec(&xprt->sc_dma_used); |
Tom Tucker | b432e6b | 2010-10-12 15:33:52 -0500 | [diff] [blame] | 125 | ib_dma_unmap_page(xprt->sc_cm_id->device, |
Tom Tucker | 64be8608 | 2008-10-06 14:45:18 -0500 | [diff] [blame] | 126 | ctxt->sge[i].addr, |
| 127 | ctxt->sge[i].length, |
| 128 | ctxt->direction); |
| 129 | } |
Tom Tucker | e6ab914 | 2008-05-28 12:08:48 -0500 | [diff] [blame] | 130 | } |
| 131 | } |
| 132 | |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 133 | void svc_rdma_put_context(struct svc_rdma_op_ctxt *ctxt, int free_pages) |
| 134 | { |
| 135 | struct svcxprt_rdma *xprt; |
| 136 | int i; |
| 137 | |
| 138 | BUG_ON(!ctxt); |
| 139 | xprt = ctxt->xprt; |
| 140 | if (free_pages) |
| 141 | for (i = 0; i < ctxt->count; i++) |
| 142 | put_page(ctxt->pages[i]); |
| 143 | |
Tom Tucker | 8948896 | 2008-05-28 15:14:02 -0500 | [diff] [blame] | 144 | kmem_cache_free(svc_rdma_ctxt_cachep, ctxt); |
Tom Tucker | 8740767 | 2008-04-30 20:44:39 -0500 | [diff] [blame] | 145 | atomic_dec(&xprt->sc_ctxt_used); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 146 | } |
| 147 | |
Tom Tucker | ab96ddd | 2008-05-28 13:54:04 -0500 | [diff] [blame] | 148 | /* |
| 149 | * Temporary NFS req mappings are shared across all transport |
| 150 | * instances. These are short lived and should be bounded by the number |
| 151 | * of concurrent server threads * depth of the SQ. |
| 152 | */ |
| 153 | struct svc_rdma_req_map *svc_rdma_get_req_map(void) |
| 154 | { |
| 155 | struct svc_rdma_req_map *map; |
| 156 | while (1) { |
| 157 | map = kmem_cache_alloc(svc_rdma_map_cachep, GFP_KERNEL); |
| 158 | if (map) |
| 159 | break; |
| 160 | schedule_timeout_uninterruptible(msecs_to_jiffies(500)); |
| 161 | } |
| 162 | map->count = 0; |
Tom Tucker | 64be8608 | 2008-10-06 14:45:18 -0500 | [diff] [blame] | 163 | map->frmr = NULL; |
Tom Tucker | ab96ddd | 2008-05-28 13:54:04 -0500 | [diff] [blame] | 164 | return map; |
| 165 | } |
| 166 | |
| 167 | void svc_rdma_put_req_map(struct svc_rdma_req_map *map) |
| 168 | { |
| 169 | kmem_cache_free(svc_rdma_map_cachep, map); |
| 170 | } |
| 171 | |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 172 | /* ib_cq event handler */ |
| 173 | static void cq_event_handler(struct ib_event *event, void *context) |
| 174 | { |
| 175 | struct svc_xprt *xprt = context; |
| 176 | dprintk("svcrdma: received CQ event id=%d, context=%p\n", |
| 177 | event->event, context); |
| 178 | set_bit(XPT_CLOSE, &xprt->xpt_flags); |
| 179 | } |
| 180 | |
| 181 | /* QP event handler */ |
| 182 | static void qp_event_handler(struct ib_event *event, void *context) |
| 183 | { |
| 184 | struct svc_xprt *xprt = context; |
| 185 | |
| 186 | switch (event->event) { |
| 187 | /* These are considered benign events */ |
| 188 | case IB_EVENT_PATH_MIG: |
| 189 | case IB_EVENT_COMM_EST: |
| 190 | case IB_EVENT_SQ_DRAINED: |
| 191 | case IB_EVENT_QP_LAST_WQE_REACHED: |
| 192 | dprintk("svcrdma: QP event %d received for QP=%p\n", |
| 193 | event->event, event->element.qp); |
| 194 | break; |
| 195 | /* These are considered fatal events */ |
| 196 | case IB_EVENT_PATH_MIG_ERR: |
| 197 | case IB_EVENT_QP_FATAL: |
| 198 | case IB_EVENT_QP_REQ_ERR: |
| 199 | case IB_EVENT_QP_ACCESS_ERR: |
| 200 | case IB_EVENT_DEVICE_FATAL: |
| 201 | default: |
| 202 | dprintk("svcrdma: QP ERROR event %d received for QP=%p, " |
| 203 | "closing transport\n", |
| 204 | event->event, event->element.qp); |
| 205 | set_bit(XPT_CLOSE, &xprt->xpt_flags); |
| 206 | break; |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | /* |
| 211 | * Data Transfer Operation Tasklet |
| 212 | * |
| 213 | * Walks a list of transports with I/O pending, removing entries as |
| 214 | * they are added to the server's I/O pending list. Two bits indicate |
| 215 | * if SQ, RQ, or both have I/O pending. The dto_lock is an irqsave |
| 216 | * spinlock that serializes access to the transport list with the RQ |
| 217 | * and SQ interrupt handlers. |
| 218 | */ |
| 219 | static void dto_tasklet_func(unsigned long data) |
| 220 | { |
| 221 | struct svcxprt_rdma *xprt; |
| 222 | unsigned long flags; |
| 223 | |
| 224 | spin_lock_irqsave(&dto_lock, flags); |
| 225 | while (!list_empty(&dto_xprt_q)) { |
| 226 | xprt = list_entry(dto_xprt_q.next, |
| 227 | struct svcxprt_rdma, sc_dto_q); |
| 228 | list_del_init(&xprt->sc_dto_q); |
| 229 | spin_unlock_irqrestore(&dto_lock, flags); |
| 230 | |
Tom Tucker | dbcd00e | 2008-05-06 11:33:11 -0500 | [diff] [blame] | 231 | rq_cq_reap(xprt); |
| 232 | sq_cq_reap(xprt); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 233 | |
Tom Tucker | c48cbb4 | 2008-03-11 14:31:39 -0400 | [diff] [blame] | 234 | svc_xprt_put(&xprt->sc_xprt); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 235 | spin_lock_irqsave(&dto_lock, flags); |
| 236 | } |
| 237 | spin_unlock_irqrestore(&dto_lock, flags); |
| 238 | } |
| 239 | |
| 240 | /* |
| 241 | * Receive Queue Completion Handler |
| 242 | * |
| 243 | * Since an RQ completion handler is called on interrupt context, we |
| 244 | * need to defer the handling of the I/O to a tasklet |
| 245 | */ |
| 246 | static void rq_comp_handler(struct ib_cq *cq, void *cq_context) |
| 247 | { |
| 248 | struct svcxprt_rdma *xprt = cq_context; |
| 249 | unsigned long flags; |
| 250 | |
Tom Tucker | 1711386 | 2008-05-01 11:13:50 -0500 | [diff] [blame] | 251 | /* Guard against unconditional flush call for destroyed QP */ |
| 252 | if (atomic_read(&xprt->sc_xprt.xpt_ref.refcount)==0) |
| 253 | return; |
| 254 | |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 255 | /* |
| 256 | * Set the bit regardless of whether or not it's on the list |
| 257 | * because it may be on the list already due to an SQ |
| 258 | * completion. |
Tom Tucker | 1711386 | 2008-05-01 11:13:50 -0500 | [diff] [blame] | 259 | */ |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 260 | set_bit(RDMAXPRT_RQ_PENDING, &xprt->sc_flags); |
| 261 | |
| 262 | /* |
| 263 | * If this transport is not already on the DTO transport queue, |
| 264 | * add it |
| 265 | */ |
| 266 | spin_lock_irqsave(&dto_lock, flags); |
Tom Tucker | c48cbb4 | 2008-03-11 14:31:39 -0400 | [diff] [blame] | 267 | if (list_empty(&xprt->sc_dto_q)) { |
| 268 | svc_xprt_get(&xprt->sc_xprt); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 269 | list_add_tail(&xprt->sc_dto_q, &dto_xprt_q); |
Tom Tucker | c48cbb4 | 2008-03-11 14:31:39 -0400 | [diff] [blame] | 270 | } |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 271 | spin_unlock_irqrestore(&dto_lock, flags); |
| 272 | |
| 273 | /* Tasklet does all the work to avoid irqsave locks. */ |
| 274 | tasklet_schedule(&dto_tasklet); |
| 275 | } |
| 276 | |
| 277 | /* |
| 278 | * rq_cq_reap - Process the RQ CQ. |
| 279 | * |
| 280 | * Take all completing WC off the CQE and enqueue the associated DTO |
| 281 | * context on the dto_q for the transport. |
Tom Tucker | 0905c0f | 2008-05-01 10:49:03 -0500 | [diff] [blame] | 282 | * |
| 283 | * Note that caller must hold a transport reference. |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 284 | */ |
| 285 | static void rq_cq_reap(struct svcxprt_rdma *xprt) |
| 286 | { |
| 287 | int ret; |
| 288 | struct ib_wc wc; |
| 289 | struct svc_rdma_op_ctxt *ctxt = NULL; |
| 290 | |
Tom Tucker | dbcd00e | 2008-05-06 11:33:11 -0500 | [diff] [blame] | 291 | if (!test_and_clear_bit(RDMAXPRT_RQ_PENDING, &xprt->sc_flags)) |
| 292 | return; |
| 293 | |
| 294 | ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 295 | atomic_inc(&rdma_stat_rq_poll); |
| 296 | |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 297 | while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) { |
| 298 | ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id; |
| 299 | ctxt->wc_status = wc.status; |
| 300 | ctxt->byte_len = wc.byte_len; |
Tom Tucker | e6ab914 | 2008-05-28 12:08:48 -0500 | [diff] [blame] | 301 | svc_rdma_unmap_dma(ctxt); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 302 | if (wc.status != IB_WC_SUCCESS) { |
| 303 | /* Close the transport */ |
Tom Tucker | 0905c0f | 2008-05-01 10:49:03 -0500 | [diff] [blame] | 304 | dprintk("svcrdma: transport closing putting ctxt %p\n", ctxt); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 305 | set_bit(XPT_CLOSE, &xprt->sc_xprt.xpt_flags); |
| 306 | svc_rdma_put_context(ctxt, 1); |
Tom Tucker | 0905c0f | 2008-05-01 10:49:03 -0500 | [diff] [blame] | 307 | svc_xprt_put(&xprt->sc_xprt); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 308 | continue; |
| 309 | } |
Tom Tucker | 47698e0 | 2008-05-06 11:49:05 -0500 | [diff] [blame] | 310 | spin_lock_bh(&xprt->sc_rq_dto_lock); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 311 | list_add_tail(&ctxt->dto_q, &xprt->sc_rq_dto_q); |
Tom Tucker | 47698e0 | 2008-05-06 11:49:05 -0500 | [diff] [blame] | 312 | spin_unlock_bh(&xprt->sc_rq_dto_lock); |
Tom Tucker | 0905c0f | 2008-05-01 10:49:03 -0500 | [diff] [blame] | 313 | svc_xprt_put(&xprt->sc_xprt); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 314 | } |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 315 | |
| 316 | if (ctxt) |
| 317 | atomic_inc(&rdma_stat_rq_prod); |
Tom Tucker | dbcd00e | 2008-05-06 11:33:11 -0500 | [diff] [blame] | 318 | |
| 319 | set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags); |
| 320 | /* |
| 321 | * If data arrived before established event, |
| 322 | * don't enqueue. This defers RPC I/O until the |
| 323 | * RDMA connection is complete. |
| 324 | */ |
| 325 | if (!test_bit(RDMAXPRT_CONN_PENDING, &xprt->sc_flags)) |
| 326 | svc_xprt_enqueue(&xprt->sc_xprt); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 327 | } |
| 328 | |
| 329 | /* |
Justin P. Mattock | 70f23fd | 2011-05-10 10:16:21 +0200 | [diff] [blame] | 330 | * Process a completion context |
Tom Tucker | e118321 | 2008-10-03 15:22:18 -0500 | [diff] [blame] | 331 | */ |
| 332 | static void process_context(struct svcxprt_rdma *xprt, |
| 333 | struct svc_rdma_op_ctxt *ctxt) |
| 334 | { |
| 335 | svc_rdma_unmap_dma(ctxt); |
| 336 | |
| 337 | switch (ctxt->wr_op) { |
| 338 | case IB_WR_SEND: |
Tom Tucker | afd566e | 2008-10-03 15:45:03 -0500 | [diff] [blame] | 339 | if (test_bit(RDMACTXT_F_FAST_UNREG, &ctxt->flags)) |
| 340 | svc_rdma_put_frmr(xprt, ctxt->frmr); |
Tom Tucker | e118321 | 2008-10-03 15:22:18 -0500 | [diff] [blame] | 341 | svc_rdma_put_context(ctxt, 1); |
| 342 | break; |
| 343 | |
| 344 | case IB_WR_RDMA_WRITE: |
| 345 | svc_rdma_put_context(ctxt, 0); |
| 346 | break; |
| 347 | |
| 348 | case IB_WR_RDMA_READ: |
Tom Tucker | 146b6df | 2008-08-12 15:12:10 -0500 | [diff] [blame] | 349 | case IB_WR_RDMA_READ_WITH_INV: |
Tom Tucker | e118321 | 2008-10-03 15:22:18 -0500 | [diff] [blame] | 350 | if (test_bit(RDMACTXT_F_LAST_CTXT, &ctxt->flags)) { |
| 351 | struct svc_rdma_op_ctxt *read_hdr = ctxt->read_hdr; |
| 352 | BUG_ON(!read_hdr); |
Tom Tucker | 146b6df | 2008-08-12 15:12:10 -0500 | [diff] [blame] | 353 | if (test_bit(RDMACTXT_F_FAST_UNREG, &ctxt->flags)) |
| 354 | svc_rdma_put_frmr(xprt, ctxt->frmr); |
Tom Tucker | e118321 | 2008-10-03 15:22:18 -0500 | [diff] [blame] | 355 | spin_lock_bh(&xprt->sc_rq_dto_lock); |
| 356 | set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags); |
| 357 | list_add_tail(&read_hdr->dto_q, |
| 358 | &xprt->sc_read_complete_q); |
| 359 | spin_unlock_bh(&xprt->sc_rq_dto_lock); |
| 360 | svc_xprt_enqueue(&xprt->sc_xprt); |
| 361 | } |
| 362 | svc_rdma_put_context(ctxt, 0); |
| 363 | break; |
| 364 | |
| 365 | default: |
| 366 | printk(KERN_ERR "svcrdma: unexpected completion type, " |
| 367 | "opcode=%d\n", |
| 368 | ctxt->wr_op); |
| 369 | break; |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | /* |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 374 | * Send Queue Completion Handler - potentially called on interrupt context. |
Tom Tucker | 0905c0f | 2008-05-01 10:49:03 -0500 | [diff] [blame] | 375 | * |
| 376 | * Note that caller must hold a transport reference. |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 377 | */ |
| 378 | static void sq_cq_reap(struct svcxprt_rdma *xprt) |
| 379 | { |
| 380 | struct svc_rdma_op_ctxt *ctxt = NULL; |
| 381 | struct ib_wc wc; |
| 382 | struct ib_cq *cq = xprt->sc_sq_cq; |
| 383 | int ret; |
| 384 | |
Tom Tucker | dbcd00e | 2008-05-06 11:33:11 -0500 | [diff] [blame] | 385 | if (!test_and_clear_bit(RDMAXPRT_SQ_PENDING, &xprt->sc_flags)) |
| 386 | return; |
| 387 | |
| 388 | ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 389 | atomic_inc(&rdma_stat_sq_poll); |
| 390 | while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) { |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 391 | if (wc.status != IB_WC_SUCCESS) |
| 392 | /* Close the transport */ |
| 393 | set_bit(XPT_CLOSE, &xprt->sc_xprt.xpt_flags); |
| 394 | |
| 395 | /* Decrement used SQ WR count */ |
| 396 | atomic_dec(&xprt->sc_sq_count); |
| 397 | wake_up(&xprt->sc_send_wait); |
| 398 | |
Tom Tucker | e118321 | 2008-10-03 15:22:18 -0500 | [diff] [blame] | 399 | ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id; |
| 400 | if (ctxt) |
| 401 | process_context(xprt, ctxt); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 402 | |
Tom Tucker | 0905c0f | 2008-05-01 10:49:03 -0500 | [diff] [blame] | 403 | svc_xprt_put(&xprt->sc_xprt); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 404 | } |
| 405 | |
| 406 | if (ctxt) |
| 407 | atomic_inc(&rdma_stat_sq_prod); |
| 408 | } |
| 409 | |
| 410 | static void sq_comp_handler(struct ib_cq *cq, void *cq_context) |
| 411 | { |
| 412 | struct svcxprt_rdma *xprt = cq_context; |
| 413 | unsigned long flags; |
| 414 | |
Tom Tucker | 1711386 | 2008-05-01 11:13:50 -0500 | [diff] [blame] | 415 | /* Guard against unconditional flush call for destroyed QP */ |
| 416 | if (atomic_read(&xprt->sc_xprt.xpt_ref.refcount)==0) |
| 417 | return; |
| 418 | |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 419 | /* |
| 420 | * Set the bit regardless of whether or not it's on the list |
| 421 | * because it may be on the list already due to an RQ |
| 422 | * completion. |
Tom Tucker | 1711386 | 2008-05-01 11:13:50 -0500 | [diff] [blame] | 423 | */ |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 424 | set_bit(RDMAXPRT_SQ_PENDING, &xprt->sc_flags); |
| 425 | |
| 426 | /* |
| 427 | * If this transport is not already on the DTO transport queue, |
| 428 | * add it |
| 429 | */ |
| 430 | spin_lock_irqsave(&dto_lock, flags); |
Tom Tucker | c48cbb4 | 2008-03-11 14:31:39 -0400 | [diff] [blame] | 431 | if (list_empty(&xprt->sc_dto_q)) { |
| 432 | svc_xprt_get(&xprt->sc_xprt); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 433 | list_add_tail(&xprt->sc_dto_q, &dto_xprt_q); |
Tom Tucker | c48cbb4 | 2008-03-11 14:31:39 -0400 | [diff] [blame] | 434 | } |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 435 | spin_unlock_irqrestore(&dto_lock, flags); |
| 436 | |
| 437 | /* Tasklet does all the work to avoid irqsave locks. */ |
| 438 | tasklet_schedule(&dto_tasklet); |
| 439 | } |
| 440 | |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 441 | static struct svcxprt_rdma *rdma_create_xprt(struct svc_serv *serv, |
| 442 | int listener) |
| 443 | { |
| 444 | struct svcxprt_rdma *cma_xprt = kzalloc(sizeof *cma_xprt, GFP_KERNEL); |
| 445 | |
| 446 | if (!cma_xprt) |
| 447 | return NULL; |
Stanislav Kinsbursky | bd4620d | 2011-12-06 14:19:10 +0300 | [diff] [blame] | 448 | svc_xprt_init(&init_net, &svc_rdma_class, &cma_xprt->sc_xprt, serv); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 449 | INIT_LIST_HEAD(&cma_xprt->sc_accept_q); |
| 450 | INIT_LIST_HEAD(&cma_xprt->sc_dto_q); |
| 451 | INIT_LIST_HEAD(&cma_xprt->sc_rq_dto_q); |
| 452 | INIT_LIST_HEAD(&cma_xprt->sc_read_complete_q); |
Tom Tucker | 64be8608 | 2008-10-06 14:45:18 -0500 | [diff] [blame] | 453 | INIT_LIST_HEAD(&cma_xprt->sc_frmr_q); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 454 | init_waitqueue_head(&cma_xprt->sc_send_wait); |
| 455 | |
| 456 | spin_lock_init(&cma_xprt->sc_lock); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 457 | spin_lock_init(&cma_xprt->sc_rq_dto_lock); |
Tom Tucker | 64be8608 | 2008-10-06 14:45:18 -0500 | [diff] [blame] | 458 | spin_lock_init(&cma_xprt->sc_frmr_q_lock); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 459 | |
| 460 | cma_xprt->sc_ord = svcrdma_ord; |
| 461 | |
| 462 | cma_xprt->sc_max_req_size = svcrdma_max_req_size; |
| 463 | cma_xprt->sc_max_requests = svcrdma_max_requests; |
| 464 | cma_xprt->sc_sq_depth = svcrdma_max_requests * RPCRDMA_SQ_DEPTH_MULT; |
| 465 | atomic_set(&cma_xprt->sc_sq_count, 0); |
Tom Tucker | 87295b6 | 2008-05-28 13:17:44 -0500 | [diff] [blame] | 466 | atomic_set(&cma_xprt->sc_ctxt_used, 0); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 467 | |
Tom Tucker | 8948896 | 2008-05-28 15:14:02 -0500 | [diff] [blame] | 468 | if (listener) |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 469 | set_bit(XPT_LISTENER, &cma_xprt->sc_xprt.xpt_flags); |
| 470 | |
| 471 | return cma_xprt; |
| 472 | } |
| 473 | |
| 474 | struct page *svc_rdma_get_page(void) |
| 475 | { |
| 476 | struct page *page; |
| 477 | |
| 478 | while ((page = alloc_page(GFP_KERNEL)) == NULL) { |
| 479 | /* If we can't get memory, wait a bit and try again */ |
| 480 | printk(KERN_INFO "svcrdma: out of memory...retrying in 1000 " |
| 481 | "jiffies.\n"); |
| 482 | schedule_timeout_uninterruptible(msecs_to_jiffies(1000)); |
| 483 | } |
| 484 | return page; |
| 485 | } |
| 486 | |
| 487 | int svc_rdma_post_recv(struct svcxprt_rdma *xprt) |
| 488 | { |
| 489 | struct ib_recv_wr recv_wr, *bad_recv_wr; |
| 490 | struct svc_rdma_op_ctxt *ctxt; |
| 491 | struct page *page; |
Tom Tucker | a5abf4e | 2008-09-30 14:05:41 -0500 | [diff] [blame] | 492 | dma_addr_t pa; |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 493 | int sge_no; |
| 494 | int buflen; |
| 495 | int ret; |
| 496 | |
| 497 | ctxt = svc_rdma_get_context(xprt); |
| 498 | buflen = 0; |
| 499 | ctxt->direction = DMA_FROM_DEVICE; |
| 500 | for (sge_no = 0; buflen < xprt->sc_max_req_size; sge_no++) { |
| 501 | BUG_ON(sge_no >= xprt->sc_max_sge); |
| 502 | page = svc_rdma_get_page(); |
| 503 | ctxt->pages[sge_no] = page; |
Tom Tucker | b432e6b | 2010-10-12 15:33:52 -0500 | [diff] [blame] | 504 | pa = ib_dma_map_page(xprt->sc_cm_id->device, |
| 505 | page, 0, PAGE_SIZE, |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 506 | DMA_FROM_DEVICE); |
Tom Tucker | a5abf4e | 2008-09-30 14:05:41 -0500 | [diff] [blame] | 507 | if (ib_dma_mapping_error(xprt->sc_cm_id->device, pa)) |
| 508 | goto err_put_ctxt; |
| 509 | atomic_inc(&xprt->sc_dma_used); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 510 | ctxt->sge[sge_no].addr = pa; |
| 511 | ctxt->sge[sge_no].length = PAGE_SIZE; |
Tom Tucker | a5abf4e | 2008-09-30 14:05:41 -0500 | [diff] [blame] | 512 | ctxt->sge[sge_no].lkey = xprt->sc_dma_lkey; |
Tom Tucker | 4a84386 | 2010-10-12 15:33:57 -0500 | [diff] [blame] | 513 | ctxt->count = sge_no + 1; |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 514 | buflen += PAGE_SIZE; |
| 515 | } |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 516 | recv_wr.next = NULL; |
| 517 | recv_wr.sg_list = &ctxt->sge[0]; |
| 518 | recv_wr.num_sge = ctxt->count; |
| 519 | recv_wr.wr_id = (u64)(unsigned long)ctxt; |
| 520 | |
Tom Tucker | 0905c0f | 2008-05-01 10:49:03 -0500 | [diff] [blame] | 521 | svc_xprt_get(&xprt->sc_xprt); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 522 | ret = ib_post_recv(xprt->sc_qp, &recv_wr, &bad_recv_wr); |
Tom Tucker | 0905c0f | 2008-05-01 10:49:03 -0500 | [diff] [blame] | 523 | if (ret) { |
Steve Wise | 21515e4 | 2009-04-29 14:14:00 -0500 | [diff] [blame] | 524 | svc_rdma_unmap_dma(ctxt); |
Tom Tucker | 05a0826 | 2008-04-25 14:11:31 -0500 | [diff] [blame] | 525 | svc_rdma_put_context(ctxt, 1); |
Steve Wise | 21515e4 | 2009-04-29 14:14:00 -0500 | [diff] [blame] | 526 | svc_xprt_put(&xprt->sc_xprt); |
Tom Tucker | 0905c0f | 2008-05-01 10:49:03 -0500 | [diff] [blame] | 527 | } |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 528 | return ret; |
Tom Tucker | a5abf4e | 2008-09-30 14:05:41 -0500 | [diff] [blame] | 529 | |
| 530 | err_put_ctxt: |
Tom Tucker | 4a84386 | 2010-10-12 15:33:57 -0500 | [diff] [blame] | 531 | svc_rdma_unmap_dma(ctxt); |
Tom Tucker | a5abf4e | 2008-09-30 14:05:41 -0500 | [diff] [blame] | 532 | svc_rdma_put_context(ctxt, 1); |
| 533 | return -ENOMEM; |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 534 | } |
| 535 | |
| 536 | /* |
| 537 | * This function handles the CONNECT_REQUEST event on a listening |
| 538 | * endpoint. It is passed the cma_id for the _new_ connection. The context in |
| 539 | * this cma_id is inherited from the listening cma_id and is the svc_xprt |
| 540 | * structure for the listening endpoint. |
| 541 | * |
| 542 | * This function creates a new xprt for the new connection and enqueues it on |
| 543 | * the accept queue for the listent xprt. When the listen thread is kicked, it |
| 544 | * will call the recvfrom method on the listen xprt which will accept the new |
| 545 | * connection. |
| 546 | */ |
Tom Tucker | 36ef25e | 2008-05-19 19:00:24 -0500 | [diff] [blame] | 547 | static void handle_connect_req(struct rdma_cm_id *new_cma_id, size_t client_ird) |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 548 | { |
| 549 | struct svcxprt_rdma *listen_xprt = new_cma_id->context; |
| 550 | struct svcxprt_rdma *newxprt; |
Tom Tucker | af261af | 2008-05-07 13:52:42 -0500 | [diff] [blame] | 551 | struct sockaddr *sa; |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 552 | |
| 553 | /* Create a new transport */ |
| 554 | newxprt = rdma_create_xprt(listen_xprt->sc_xprt.xpt_server, 0); |
| 555 | if (!newxprt) { |
| 556 | dprintk("svcrdma: failed to create new transport\n"); |
| 557 | return; |
| 558 | } |
| 559 | newxprt->sc_cm_id = new_cma_id; |
| 560 | new_cma_id->context = newxprt; |
| 561 | dprintk("svcrdma: Creating newxprt=%p, cm_id=%p, listenxprt=%p\n", |
| 562 | newxprt, newxprt->sc_cm_id, listen_xprt); |
| 563 | |
Tom Tucker | 36ef25e | 2008-05-19 19:00:24 -0500 | [diff] [blame] | 564 | /* Save client advertised inbound read limit for use later in accept. */ |
| 565 | newxprt->sc_ord = client_ird; |
| 566 | |
Tom Tucker | af261af | 2008-05-07 13:52:42 -0500 | [diff] [blame] | 567 | /* Set the local and remote addresses in the transport */ |
| 568 | sa = (struct sockaddr *)&newxprt->sc_cm_id->route.addr.dst_addr; |
| 569 | svc_xprt_set_remote(&newxprt->sc_xprt, sa, svc_addr_len(sa)); |
| 570 | sa = (struct sockaddr *)&newxprt->sc_cm_id->route.addr.src_addr; |
| 571 | svc_xprt_set_local(&newxprt->sc_xprt, sa, svc_addr_len(sa)); |
| 572 | |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 573 | /* |
| 574 | * Enqueue the new transport on the accept queue of the listening |
| 575 | * transport |
| 576 | */ |
| 577 | spin_lock_bh(&listen_xprt->sc_lock); |
| 578 | list_add_tail(&newxprt->sc_accept_q, &listen_xprt->sc_accept_q); |
| 579 | spin_unlock_bh(&listen_xprt->sc_lock); |
| 580 | |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 581 | set_bit(XPT_CONN, &listen_xprt->sc_xprt.xpt_flags); |
| 582 | svc_xprt_enqueue(&listen_xprt->sc_xprt); |
| 583 | } |
| 584 | |
| 585 | /* |
| 586 | * Handles events generated on the listening endpoint. These events will be |
| 587 | * either be incoming connect requests or adapter removal events. |
| 588 | */ |
| 589 | static int rdma_listen_handler(struct rdma_cm_id *cma_id, |
| 590 | struct rdma_cm_event *event) |
| 591 | { |
| 592 | struct svcxprt_rdma *xprt = cma_id->context; |
| 593 | int ret = 0; |
| 594 | |
| 595 | switch (event->event) { |
| 596 | case RDMA_CM_EVENT_CONNECT_REQUEST: |
| 597 | dprintk("svcrdma: Connect request on cma_id=%p, xprt = %p, " |
| 598 | "event=%d\n", cma_id, cma_id->context, event->event); |
Tom Tucker | 36ef25e | 2008-05-19 19:00:24 -0500 | [diff] [blame] | 599 | handle_connect_req(cma_id, |
Tom Tucker | 67080c8 | 2008-10-03 12:41:14 -0500 | [diff] [blame] | 600 | event->param.conn.initiator_depth); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 601 | break; |
| 602 | |
| 603 | case RDMA_CM_EVENT_ESTABLISHED: |
| 604 | /* Accept complete */ |
| 605 | dprintk("svcrdma: Connection completed on LISTEN xprt=%p, " |
| 606 | "cm_id=%p\n", xprt, cma_id); |
| 607 | break; |
| 608 | |
| 609 | case RDMA_CM_EVENT_DEVICE_REMOVAL: |
| 610 | dprintk("svcrdma: Device removal xprt=%p, cm_id=%p\n", |
| 611 | xprt, cma_id); |
| 612 | if (xprt) |
| 613 | set_bit(XPT_CLOSE, &xprt->sc_xprt.xpt_flags); |
| 614 | break; |
| 615 | |
| 616 | default: |
| 617 | dprintk("svcrdma: Unexpected event on listening endpoint %p, " |
| 618 | "event=%d\n", cma_id, event->event); |
| 619 | break; |
| 620 | } |
| 621 | |
| 622 | return ret; |
| 623 | } |
| 624 | |
| 625 | static int rdma_cma_handler(struct rdma_cm_id *cma_id, |
| 626 | struct rdma_cm_event *event) |
| 627 | { |
| 628 | struct svc_xprt *xprt = cma_id->context; |
| 629 | struct svcxprt_rdma *rdma = |
| 630 | container_of(xprt, struct svcxprt_rdma, sc_xprt); |
| 631 | switch (event->event) { |
| 632 | case RDMA_CM_EVENT_ESTABLISHED: |
| 633 | /* Accept complete */ |
Tom Tucker | c48cbb4 | 2008-03-11 14:31:39 -0400 | [diff] [blame] | 634 | svc_xprt_get(xprt); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 635 | dprintk("svcrdma: Connection completed on DTO xprt=%p, " |
| 636 | "cm_id=%p\n", xprt, cma_id); |
| 637 | clear_bit(RDMAXPRT_CONN_PENDING, &rdma->sc_flags); |
| 638 | svc_xprt_enqueue(xprt); |
| 639 | break; |
| 640 | case RDMA_CM_EVENT_DISCONNECTED: |
| 641 | dprintk("svcrdma: Disconnect on DTO xprt=%p, cm_id=%p\n", |
| 642 | xprt, cma_id); |
| 643 | if (xprt) { |
| 644 | set_bit(XPT_CLOSE, &xprt->xpt_flags); |
| 645 | svc_xprt_enqueue(xprt); |
Tom Tucker | 120693d | 2008-04-24 14:17:21 -0500 | [diff] [blame] | 646 | svc_xprt_put(xprt); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 647 | } |
| 648 | break; |
| 649 | case RDMA_CM_EVENT_DEVICE_REMOVAL: |
| 650 | dprintk("svcrdma: Device removal cma_id=%p, xprt = %p, " |
| 651 | "event=%d\n", cma_id, xprt, event->event); |
| 652 | if (xprt) { |
| 653 | set_bit(XPT_CLOSE, &xprt->xpt_flags); |
| 654 | svc_xprt_enqueue(xprt); |
| 655 | } |
| 656 | break; |
| 657 | default: |
| 658 | dprintk("svcrdma: Unexpected event on DTO endpoint %p, " |
| 659 | "event=%d\n", cma_id, event->event); |
| 660 | break; |
| 661 | } |
| 662 | return 0; |
| 663 | } |
| 664 | |
| 665 | /* |
| 666 | * Create a listening RDMA service endpoint. |
| 667 | */ |
| 668 | static struct svc_xprt *svc_rdma_create(struct svc_serv *serv, |
Pavel Emelyanov | 62832c0 | 2010-09-29 16:04:18 +0400 | [diff] [blame] | 669 | struct net *net, |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 670 | struct sockaddr *sa, int salen, |
| 671 | int flags) |
| 672 | { |
| 673 | struct rdma_cm_id *listen_id; |
| 674 | struct svcxprt_rdma *cma_xprt; |
| 675 | struct svc_xprt *xprt; |
| 676 | int ret; |
| 677 | |
| 678 | dprintk("svcrdma: Creating RDMA socket\n"); |
Tom Tucker | bade732 | 2010-04-03 08:27:29 -0500 | [diff] [blame] | 679 | if (sa->sa_family != AF_INET) { |
| 680 | dprintk("svcrdma: Address family %d is not supported.\n", sa->sa_family); |
| 681 | return ERR_PTR(-EAFNOSUPPORT); |
| 682 | } |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 683 | cma_xprt = rdma_create_xprt(serv, 1); |
| 684 | if (!cma_xprt) |
Tom Tucker | 58e8f62 | 2008-05-06 09:45:54 -0500 | [diff] [blame] | 685 | return ERR_PTR(-ENOMEM); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 686 | xprt = &cma_xprt->sc_xprt; |
| 687 | |
Sean Hefty | b26f9b9 | 2010-04-01 17:08:41 +0000 | [diff] [blame] | 688 | listen_id = rdma_create_id(rdma_listen_handler, cma_xprt, RDMA_PS_TCP, |
| 689 | IB_QPT_RC); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 690 | if (IS_ERR(listen_id)) { |
Tom Tucker | 58e8f62 | 2008-05-06 09:45:54 -0500 | [diff] [blame] | 691 | ret = PTR_ERR(listen_id); |
| 692 | dprintk("svcrdma: rdma_create_id failed = %d\n", ret); |
| 693 | goto err0; |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 694 | } |
Tom Tucker | 58e8f62 | 2008-05-06 09:45:54 -0500 | [diff] [blame] | 695 | |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 696 | ret = rdma_bind_addr(listen_id, sa); |
| 697 | if (ret) { |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 698 | dprintk("svcrdma: rdma_bind_addr failed = %d\n", ret); |
Tom Tucker | 58e8f62 | 2008-05-06 09:45:54 -0500 | [diff] [blame] | 699 | goto err1; |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 700 | } |
| 701 | cma_xprt->sc_cm_id = listen_id; |
| 702 | |
| 703 | ret = rdma_listen(listen_id, RPCRDMA_LISTEN_BACKLOG); |
| 704 | if (ret) { |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 705 | dprintk("svcrdma: rdma_listen failed = %d\n", ret); |
Tom Tucker | 58e8f62 | 2008-05-06 09:45:54 -0500 | [diff] [blame] | 706 | goto err1; |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 707 | } |
| 708 | |
| 709 | /* |
| 710 | * We need to use the address from the cm_id in case the |
| 711 | * caller specified 0 for the port number. |
| 712 | */ |
| 713 | sa = (struct sockaddr *)&cma_xprt->sc_cm_id->route.addr.src_addr; |
| 714 | svc_xprt_set_local(&cma_xprt->sc_xprt, sa, salen); |
| 715 | |
| 716 | return &cma_xprt->sc_xprt; |
Tom Tucker | 58e8f62 | 2008-05-06 09:45:54 -0500 | [diff] [blame] | 717 | |
| 718 | err1: |
| 719 | rdma_destroy_id(listen_id); |
| 720 | err0: |
| 721 | kfree(cma_xprt); |
| 722 | return ERR_PTR(ret); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 723 | } |
| 724 | |
Tom Tucker | 64be8608 | 2008-10-06 14:45:18 -0500 | [diff] [blame] | 725 | static struct svc_rdma_fastreg_mr *rdma_alloc_frmr(struct svcxprt_rdma *xprt) |
| 726 | { |
| 727 | struct ib_mr *mr; |
| 728 | struct ib_fast_reg_page_list *pl; |
| 729 | struct svc_rdma_fastreg_mr *frmr; |
| 730 | |
| 731 | frmr = kmalloc(sizeof(*frmr), GFP_KERNEL); |
| 732 | if (!frmr) |
| 733 | goto err; |
| 734 | |
| 735 | mr = ib_alloc_fast_reg_mr(xprt->sc_pd, RPCSVC_MAXPAGES); |
Wei Yongjun | 846d8e7 | 2009-06-25 16:35:44 +0800 | [diff] [blame] | 736 | if (IS_ERR(mr)) |
Tom Tucker | 64be8608 | 2008-10-06 14:45:18 -0500 | [diff] [blame] | 737 | goto err_free_frmr; |
| 738 | |
| 739 | pl = ib_alloc_fast_reg_page_list(xprt->sc_cm_id->device, |
| 740 | RPCSVC_MAXPAGES); |
Wei Yongjun | 846d8e7 | 2009-06-25 16:35:44 +0800 | [diff] [blame] | 741 | if (IS_ERR(pl)) |
Tom Tucker | 64be8608 | 2008-10-06 14:45:18 -0500 | [diff] [blame] | 742 | goto err_free_mr; |
| 743 | |
| 744 | frmr->mr = mr; |
| 745 | frmr->page_list = pl; |
| 746 | INIT_LIST_HEAD(&frmr->frmr_list); |
| 747 | return frmr; |
| 748 | |
| 749 | err_free_mr: |
| 750 | ib_dereg_mr(mr); |
| 751 | err_free_frmr: |
| 752 | kfree(frmr); |
| 753 | err: |
| 754 | return ERR_PTR(-ENOMEM); |
| 755 | } |
| 756 | |
| 757 | static void rdma_dealloc_frmr_q(struct svcxprt_rdma *xprt) |
| 758 | { |
| 759 | struct svc_rdma_fastreg_mr *frmr; |
| 760 | |
| 761 | while (!list_empty(&xprt->sc_frmr_q)) { |
| 762 | frmr = list_entry(xprt->sc_frmr_q.next, |
| 763 | struct svc_rdma_fastreg_mr, frmr_list); |
| 764 | list_del_init(&frmr->frmr_list); |
| 765 | ib_dereg_mr(frmr->mr); |
| 766 | ib_free_fast_reg_page_list(frmr->page_list); |
| 767 | kfree(frmr); |
| 768 | } |
| 769 | } |
| 770 | |
| 771 | struct svc_rdma_fastreg_mr *svc_rdma_get_frmr(struct svcxprt_rdma *rdma) |
| 772 | { |
| 773 | struct svc_rdma_fastreg_mr *frmr = NULL; |
| 774 | |
| 775 | spin_lock_bh(&rdma->sc_frmr_q_lock); |
| 776 | if (!list_empty(&rdma->sc_frmr_q)) { |
| 777 | frmr = list_entry(rdma->sc_frmr_q.next, |
| 778 | struct svc_rdma_fastreg_mr, frmr_list); |
| 779 | list_del_init(&frmr->frmr_list); |
| 780 | frmr->map_len = 0; |
| 781 | frmr->page_list_len = 0; |
| 782 | } |
| 783 | spin_unlock_bh(&rdma->sc_frmr_q_lock); |
| 784 | if (frmr) |
| 785 | return frmr; |
| 786 | |
| 787 | return rdma_alloc_frmr(rdma); |
| 788 | } |
| 789 | |
| 790 | static void frmr_unmap_dma(struct svcxprt_rdma *xprt, |
| 791 | struct svc_rdma_fastreg_mr *frmr) |
| 792 | { |
| 793 | int page_no; |
| 794 | for (page_no = 0; page_no < frmr->page_list_len; page_no++) { |
| 795 | dma_addr_t addr = frmr->page_list->page_list[page_no]; |
| 796 | if (ib_dma_mapping_error(frmr->mr->device, addr)) |
| 797 | continue; |
| 798 | atomic_dec(&xprt->sc_dma_used); |
Tom Tucker | b432e6b | 2010-10-12 15:33:52 -0500 | [diff] [blame] | 799 | ib_dma_unmap_page(frmr->mr->device, addr, PAGE_SIZE, |
| 800 | frmr->direction); |
Tom Tucker | 64be8608 | 2008-10-06 14:45:18 -0500 | [diff] [blame] | 801 | } |
| 802 | } |
| 803 | |
| 804 | void svc_rdma_put_frmr(struct svcxprt_rdma *rdma, |
| 805 | struct svc_rdma_fastreg_mr *frmr) |
| 806 | { |
| 807 | if (frmr) { |
| 808 | frmr_unmap_dma(rdma, frmr); |
| 809 | spin_lock_bh(&rdma->sc_frmr_q_lock); |
| 810 | BUG_ON(!list_empty(&frmr->frmr_list)); |
| 811 | list_add(&frmr->frmr_list, &rdma->sc_frmr_q); |
| 812 | spin_unlock_bh(&rdma->sc_frmr_q_lock); |
| 813 | } |
| 814 | } |
| 815 | |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 816 | /* |
| 817 | * This is the xpo_recvfrom function for listening endpoints. Its |
| 818 | * purpose is to accept incoming connections. The CMA callback handler |
| 819 | * has already created a new transport and attached it to the new CMA |
| 820 | * ID. |
| 821 | * |
| 822 | * There is a queue of pending connections hung on the listening |
| 823 | * transport. This queue contains the new svc_xprt structure. This |
| 824 | * function takes svc_xprt structures off the accept_q and completes |
| 825 | * the connection. |
| 826 | */ |
| 827 | static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt) |
| 828 | { |
| 829 | struct svcxprt_rdma *listen_rdma; |
| 830 | struct svcxprt_rdma *newxprt = NULL; |
| 831 | struct rdma_conn_param conn_param; |
| 832 | struct ib_qp_init_attr qp_attr; |
| 833 | struct ib_device_attr devattr; |
Ingo Molnar | ed72b9c | 2008-11-25 16:49:37 -0800 | [diff] [blame] | 834 | int uninitialized_var(dma_mr_acc); |
Tom Tucker | 3a5c638 | 2008-09-30 13:46:13 -0500 | [diff] [blame] | 835 | int need_dma_mr; |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 836 | int ret; |
| 837 | int i; |
| 838 | |
| 839 | listen_rdma = container_of(xprt, struct svcxprt_rdma, sc_xprt); |
| 840 | clear_bit(XPT_CONN, &xprt->xpt_flags); |
| 841 | /* Get the next entry off the accept list */ |
| 842 | spin_lock_bh(&listen_rdma->sc_lock); |
| 843 | if (!list_empty(&listen_rdma->sc_accept_q)) { |
| 844 | newxprt = list_entry(listen_rdma->sc_accept_q.next, |
| 845 | struct svcxprt_rdma, sc_accept_q); |
| 846 | list_del_init(&newxprt->sc_accept_q); |
| 847 | } |
| 848 | if (!list_empty(&listen_rdma->sc_accept_q)) |
| 849 | set_bit(XPT_CONN, &listen_rdma->sc_xprt.xpt_flags); |
| 850 | spin_unlock_bh(&listen_rdma->sc_lock); |
| 851 | if (!newxprt) |
| 852 | return NULL; |
| 853 | |
| 854 | dprintk("svcrdma: newxprt from accept queue = %p, cm_id=%p\n", |
| 855 | newxprt, newxprt->sc_cm_id); |
| 856 | |
| 857 | ret = ib_query_device(newxprt->sc_cm_id->device, &devattr); |
| 858 | if (ret) { |
| 859 | dprintk("svcrdma: could not query device attributes on " |
| 860 | "device %p, rc=%d\n", newxprt->sc_cm_id->device, ret); |
| 861 | goto errout; |
| 862 | } |
| 863 | |
| 864 | /* Qualify the transport resource defaults with the |
| 865 | * capabilities of this particular device */ |
| 866 | newxprt->sc_max_sge = min((size_t)devattr.max_sge, |
| 867 | (size_t)RPCSVC_MAXPAGES); |
| 868 | newxprt->sc_max_requests = min((size_t)devattr.max_qp_wr, |
| 869 | (size_t)svcrdma_max_requests); |
| 870 | newxprt->sc_sq_depth = RPCRDMA_SQ_DEPTH_MULT * newxprt->sc_max_requests; |
| 871 | |
Tom Tucker | 36ef25e | 2008-05-19 19:00:24 -0500 | [diff] [blame] | 872 | /* |
| 873 | * Limit ORD based on client limit, local device limit, and |
| 874 | * configured svcrdma limit. |
| 875 | */ |
| 876 | newxprt->sc_ord = min_t(size_t, devattr.max_qp_rd_atom, newxprt->sc_ord); |
| 877 | newxprt->sc_ord = min_t(size_t, svcrdma_ord, newxprt->sc_ord); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 878 | |
| 879 | newxprt->sc_pd = ib_alloc_pd(newxprt->sc_cm_id->device); |
| 880 | if (IS_ERR(newxprt->sc_pd)) { |
| 881 | dprintk("svcrdma: error creating PD for connect request\n"); |
| 882 | goto errout; |
| 883 | } |
| 884 | newxprt->sc_sq_cq = ib_create_cq(newxprt->sc_cm_id->device, |
| 885 | sq_comp_handler, |
| 886 | cq_event_handler, |
| 887 | newxprt, |
| 888 | newxprt->sc_sq_depth, |
| 889 | 0); |
| 890 | if (IS_ERR(newxprt->sc_sq_cq)) { |
| 891 | dprintk("svcrdma: error creating SQ CQ for connect request\n"); |
| 892 | goto errout; |
| 893 | } |
| 894 | newxprt->sc_rq_cq = ib_create_cq(newxprt->sc_cm_id->device, |
| 895 | rq_comp_handler, |
| 896 | cq_event_handler, |
| 897 | newxprt, |
| 898 | newxprt->sc_max_requests, |
| 899 | 0); |
| 900 | if (IS_ERR(newxprt->sc_rq_cq)) { |
| 901 | dprintk("svcrdma: error creating RQ CQ for connect request\n"); |
| 902 | goto errout; |
| 903 | } |
| 904 | |
| 905 | memset(&qp_attr, 0, sizeof qp_attr); |
| 906 | qp_attr.event_handler = qp_event_handler; |
| 907 | qp_attr.qp_context = &newxprt->sc_xprt; |
| 908 | qp_attr.cap.max_send_wr = newxprt->sc_sq_depth; |
| 909 | qp_attr.cap.max_recv_wr = newxprt->sc_max_requests; |
| 910 | qp_attr.cap.max_send_sge = newxprt->sc_max_sge; |
| 911 | qp_attr.cap.max_recv_sge = newxprt->sc_max_sge; |
| 912 | qp_attr.sq_sig_type = IB_SIGNAL_REQ_WR; |
| 913 | qp_attr.qp_type = IB_QPT_RC; |
| 914 | qp_attr.send_cq = newxprt->sc_sq_cq; |
| 915 | qp_attr.recv_cq = newxprt->sc_rq_cq; |
| 916 | dprintk("svcrdma: newxprt->sc_cm_id=%p, newxprt->sc_pd=%p\n" |
| 917 | " cm_id->device=%p, sc_pd->device=%p\n" |
| 918 | " cap.max_send_wr = %d\n" |
| 919 | " cap.max_recv_wr = %d\n" |
| 920 | " cap.max_send_sge = %d\n" |
| 921 | " cap.max_recv_sge = %d\n", |
| 922 | newxprt->sc_cm_id, newxprt->sc_pd, |
| 923 | newxprt->sc_cm_id->device, newxprt->sc_pd->device, |
| 924 | qp_attr.cap.max_send_wr, |
| 925 | qp_attr.cap.max_recv_wr, |
| 926 | qp_attr.cap.max_send_sge, |
| 927 | qp_attr.cap.max_recv_sge); |
| 928 | |
| 929 | ret = rdma_create_qp(newxprt->sc_cm_id, newxprt->sc_pd, &qp_attr); |
| 930 | if (ret) { |
| 931 | /* |
| 932 | * XXX: This is a hack. We need a xx_request_qp interface |
| 933 | * that will adjust the qp_attr's with a best-effort |
| 934 | * number |
| 935 | */ |
| 936 | qp_attr.cap.max_send_sge -= 2; |
| 937 | qp_attr.cap.max_recv_sge -= 2; |
| 938 | ret = rdma_create_qp(newxprt->sc_cm_id, newxprt->sc_pd, |
| 939 | &qp_attr); |
| 940 | if (ret) { |
| 941 | dprintk("svcrdma: failed to create QP, ret=%d\n", ret); |
| 942 | goto errout; |
| 943 | } |
| 944 | newxprt->sc_max_sge = qp_attr.cap.max_send_sge; |
| 945 | newxprt->sc_max_sge = qp_attr.cap.max_recv_sge; |
| 946 | newxprt->sc_sq_depth = qp_attr.cap.max_send_wr; |
| 947 | newxprt->sc_max_requests = qp_attr.cap.max_recv_wr; |
| 948 | } |
| 949 | newxprt->sc_qp = newxprt->sc_cm_id->qp; |
| 950 | |
Tom Tucker | 3a5c638 | 2008-09-30 13:46:13 -0500 | [diff] [blame] | 951 | /* |
| 952 | * Use the most secure set of MR resources based on the |
| 953 | * transport type and available memory management features in |
| 954 | * the device. Here's the table implemented below: |
| 955 | * |
| 956 | * Fast Global DMA Remote WR |
| 957 | * Reg LKEY MR Access |
| 958 | * Sup'd Sup'd Needed Needed |
| 959 | * |
| 960 | * IWARP N N Y Y |
| 961 | * N Y Y Y |
| 962 | * Y N Y N |
| 963 | * Y Y N - |
| 964 | * |
| 965 | * IB N N Y N |
| 966 | * N Y N - |
| 967 | * Y N Y N |
| 968 | * Y Y N - |
| 969 | * |
| 970 | * NB: iWARP requires remote write access for the data sink |
| 971 | * of an RDMA_READ. IB does not. |
| 972 | */ |
| 973 | if (devattr.device_cap_flags & IB_DEVICE_MEM_MGT_EXTENSIONS) { |
| 974 | newxprt->sc_frmr_pg_list_len = |
| 975 | devattr.max_fast_reg_page_list_len; |
| 976 | newxprt->sc_dev_caps |= SVCRDMA_DEVCAP_FAST_REG; |
| 977 | } |
| 978 | |
| 979 | /* |
| 980 | * Determine if a DMA MR is required and if so, what privs are required |
| 981 | */ |
| 982 | switch (rdma_node_get_transport(newxprt->sc_cm_id->device->node_type)) { |
| 983 | case RDMA_TRANSPORT_IWARP: |
| 984 | newxprt->sc_dev_caps |= SVCRDMA_DEVCAP_READ_W_INV; |
| 985 | if (!(newxprt->sc_dev_caps & SVCRDMA_DEVCAP_FAST_REG)) { |
| 986 | need_dma_mr = 1; |
| 987 | dma_mr_acc = |
| 988 | (IB_ACCESS_LOCAL_WRITE | |
| 989 | IB_ACCESS_REMOTE_WRITE); |
| 990 | } else if (!(devattr.device_cap_flags & IB_DEVICE_LOCAL_DMA_LKEY)) { |
| 991 | need_dma_mr = 1; |
| 992 | dma_mr_acc = IB_ACCESS_LOCAL_WRITE; |
| 993 | } else |
| 994 | need_dma_mr = 0; |
| 995 | break; |
| 996 | case RDMA_TRANSPORT_IB: |
| 997 | if (!(devattr.device_cap_flags & IB_DEVICE_LOCAL_DMA_LKEY)) { |
| 998 | need_dma_mr = 1; |
| 999 | dma_mr_acc = IB_ACCESS_LOCAL_WRITE; |
| 1000 | } else |
| 1001 | need_dma_mr = 0; |
| 1002 | break; |
| 1003 | default: |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1004 | goto errout; |
| 1005 | } |
| 1006 | |
Tom Tucker | 3a5c638 | 2008-09-30 13:46:13 -0500 | [diff] [blame] | 1007 | /* Create the DMA MR if needed, otherwise, use the DMA LKEY */ |
| 1008 | if (need_dma_mr) { |
| 1009 | /* Register all of physical memory */ |
| 1010 | newxprt->sc_phys_mr = |
| 1011 | ib_get_dma_mr(newxprt->sc_pd, dma_mr_acc); |
| 1012 | if (IS_ERR(newxprt->sc_phys_mr)) { |
| 1013 | dprintk("svcrdma: Failed to create DMA MR ret=%d\n", |
| 1014 | ret); |
| 1015 | goto errout; |
| 1016 | } |
| 1017 | newxprt->sc_dma_lkey = newxprt->sc_phys_mr->lkey; |
| 1018 | } else |
| 1019 | newxprt->sc_dma_lkey = |
| 1020 | newxprt->sc_cm_id->device->local_dma_lkey; |
| 1021 | |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1022 | /* Post receive buffers */ |
| 1023 | for (i = 0; i < newxprt->sc_max_requests; i++) { |
| 1024 | ret = svc_rdma_post_recv(newxprt); |
| 1025 | if (ret) { |
| 1026 | dprintk("svcrdma: failure posting receive buffers\n"); |
| 1027 | goto errout; |
| 1028 | } |
| 1029 | } |
| 1030 | |
| 1031 | /* Swap out the handler */ |
| 1032 | newxprt->sc_cm_id->event_handler = rdma_cma_handler; |
| 1033 | |
Tom Tucker | af261af | 2008-05-07 13:52:42 -0500 | [diff] [blame] | 1034 | /* |
| 1035 | * Arm the CQs for the SQ and RQ before accepting so we can't |
| 1036 | * miss the first message |
| 1037 | */ |
| 1038 | ib_req_notify_cq(newxprt->sc_sq_cq, IB_CQ_NEXT_COMP); |
| 1039 | ib_req_notify_cq(newxprt->sc_rq_cq, IB_CQ_NEXT_COMP); |
| 1040 | |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1041 | /* Accept Connection */ |
| 1042 | set_bit(RDMAXPRT_CONN_PENDING, &newxprt->sc_flags); |
| 1043 | memset(&conn_param, 0, sizeof conn_param); |
| 1044 | conn_param.responder_resources = 0; |
| 1045 | conn_param.initiator_depth = newxprt->sc_ord; |
| 1046 | ret = rdma_accept(newxprt->sc_cm_id, &conn_param); |
| 1047 | if (ret) { |
| 1048 | dprintk("svcrdma: failed to accept new connection, ret=%d\n", |
| 1049 | ret); |
| 1050 | goto errout; |
| 1051 | } |
| 1052 | |
| 1053 | dprintk("svcrdma: new connection %p accepted with the following " |
| 1054 | "attributes:\n" |
Harvey Harrison | 21454aa | 2008-10-31 00:54:56 -0700 | [diff] [blame] | 1055 | " local_ip : %pI4\n" |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1056 | " local_port : %d\n" |
Harvey Harrison | 21454aa | 2008-10-31 00:54:56 -0700 | [diff] [blame] | 1057 | " remote_ip : %pI4\n" |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1058 | " remote_port : %d\n" |
| 1059 | " max_sge : %d\n" |
| 1060 | " sq_depth : %d\n" |
| 1061 | " max_requests : %d\n" |
| 1062 | " ord : %d\n", |
| 1063 | newxprt, |
Harvey Harrison | 21454aa | 2008-10-31 00:54:56 -0700 | [diff] [blame] | 1064 | &((struct sockaddr_in *)&newxprt->sc_cm_id-> |
| 1065 | route.addr.src_addr)->sin_addr.s_addr, |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1066 | ntohs(((struct sockaddr_in *)&newxprt->sc_cm_id-> |
| 1067 | route.addr.src_addr)->sin_port), |
Harvey Harrison | 21454aa | 2008-10-31 00:54:56 -0700 | [diff] [blame] | 1068 | &((struct sockaddr_in *)&newxprt->sc_cm_id-> |
| 1069 | route.addr.dst_addr)->sin_addr.s_addr, |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1070 | ntohs(((struct sockaddr_in *)&newxprt->sc_cm_id-> |
| 1071 | route.addr.dst_addr)->sin_port), |
| 1072 | newxprt->sc_max_sge, |
| 1073 | newxprt->sc_sq_depth, |
| 1074 | newxprt->sc_max_requests, |
| 1075 | newxprt->sc_ord); |
| 1076 | |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1077 | return &newxprt->sc_xprt; |
| 1078 | |
| 1079 | errout: |
| 1080 | dprintk("svcrdma: failure accepting new connection rc=%d.\n", ret); |
Tom Tucker | c48cbb4 | 2008-03-11 14:31:39 -0400 | [diff] [blame] | 1081 | /* Take a reference in case the DTO handler runs */ |
| 1082 | svc_xprt_get(&newxprt->sc_xprt); |
Tom Tucker | 1711386 | 2008-05-01 11:13:50 -0500 | [diff] [blame] | 1083 | if (newxprt->sc_qp && !IS_ERR(newxprt->sc_qp)) |
Tom Tucker | c48cbb4 | 2008-03-11 14:31:39 -0400 | [diff] [blame] | 1084 | ib_destroy_qp(newxprt->sc_qp); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1085 | rdma_destroy_id(newxprt->sc_cm_id); |
Tom Tucker | c48cbb4 | 2008-03-11 14:31:39 -0400 | [diff] [blame] | 1086 | /* This call to put will destroy the transport */ |
| 1087 | svc_xprt_put(&newxprt->sc_xprt); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1088 | return NULL; |
| 1089 | } |
| 1090 | |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1091 | static void svc_rdma_release_rqst(struct svc_rqst *rqstp) |
| 1092 | { |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1093 | } |
| 1094 | |
Tom Tucker | c48cbb4 | 2008-03-11 14:31:39 -0400 | [diff] [blame] | 1095 | /* |
Tom Tucker | 1711386 | 2008-05-01 11:13:50 -0500 | [diff] [blame] | 1096 | * When connected, an svc_xprt has at least two references: |
Tom Tucker | c48cbb4 | 2008-03-11 14:31:39 -0400 | [diff] [blame] | 1097 | * |
| 1098 | * - A reference held by the cm_id between the ESTABLISHED and |
| 1099 | * DISCONNECTED events. If the remote peer disconnected first, this |
| 1100 | * reference could be gone. |
| 1101 | * |
| 1102 | * - A reference held by the svc_recv code that called this function |
| 1103 | * as part of close processing. |
| 1104 | * |
Tom Tucker | 1711386 | 2008-05-01 11:13:50 -0500 | [diff] [blame] | 1105 | * At a minimum one references should still be held. |
Tom Tucker | c48cbb4 | 2008-03-11 14:31:39 -0400 | [diff] [blame] | 1106 | */ |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1107 | static void svc_rdma_detach(struct svc_xprt *xprt) |
| 1108 | { |
| 1109 | struct svcxprt_rdma *rdma = |
| 1110 | container_of(xprt, struct svcxprt_rdma, sc_xprt); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1111 | dprintk("svc: svc_rdma_detach(%p)\n", xprt); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1112 | |
Tom Tucker | c48cbb4 | 2008-03-11 14:31:39 -0400 | [diff] [blame] | 1113 | /* Disconnect and flush posted WQE */ |
| 1114 | rdma_disconnect(rdma->sc_cm_id); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1115 | } |
| 1116 | |
Tom Tucker | 8da91ea | 2008-04-30 22:00:46 -0500 | [diff] [blame] | 1117 | static void __svc_rdma_free(struct work_struct *work) |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1118 | { |
Tom Tucker | 8da91ea | 2008-04-30 22:00:46 -0500 | [diff] [blame] | 1119 | struct svcxprt_rdma *rdma = |
| 1120 | container_of(work, struct svcxprt_rdma, sc_work); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1121 | dprintk("svcrdma: svc_rdma_free(%p)\n", rdma); |
Tom Tucker | 8da91ea | 2008-04-30 22:00:46 -0500 | [diff] [blame] | 1122 | |
Tom Tucker | c48cbb4 | 2008-03-11 14:31:39 -0400 | [diff] [blame] | 1123 | /* We should only be called from kref_put */ |
Tom Tucker | 8da91ea | 2008-04-30 22:00:46 -0500 | [diff] [blame] | 1124 | BUG_ON(atomic_read(&rdma->sc_xprt.xpt_ref.refcount) != 0); |
| 1125 | |
Tom Tucker | 356d0a1 | 2008-05-01 11:25:02 -0500 | [diff] [blame] | 1126 | /* |
| 1127 | * Destroy queued, but not processed read completions. Note |
| 1128 | * that this cleanup has to be done before destroying the |
| 1129 | * cm_id because the device ptr is needed to unmap the dma in |
| 1130 | * svc_rdma_put_context. |
| 1131 | */ |
Tom Tucker | 356d0a1 | 2008-05-01 11:25:02 -0500 | [diff] [blame] | 1132 | while (!list_empty(&rdma->sc_read_complete_q)) { |
| 1133 | struct svc_rdma_op_ctxt *ctxt; |
| 1134 | ctxt = list_entry(rdma->sc_read_complete_q.next, |
| 1135 | struct svc_rdma_op_ctxt, |
| 1136 | dto_q); |
| 1137 | list_del_init(&ctxt->dto_q); |
| 1138 | svc_rdma_put_context(ctxt, 1); |
| 1139 | } |
Tom Tucker | 356d0a1 | 2008-05-01 11:25:02 -0500 | [diff] [blame] | 1140 | |
| 1141 | /* Destroy queued, but not processed recv completions */ |
Tom Tucker | 356d0a1 | 2008-05-01 11:25:02 -0500 | [diff] [blame] | 1142 | while (!list_empty(&rdma->sc_rq_dto_q)) { |
| 1143 | struct svc_rdma_op_ctxt *ctxt; |
| 1144 | ctxt = list_entry(rdma->sc_rq_dto_q.next, |
| 1145 | struct svc_rdma_op_ctxt, |
| 1146 | dto_q); |
| 1147 | list_del_init(&ctxt->dto_q); |
| 1148 | svc_rdma_put_context(ctxt, 1); |
| 1149 | } |
Tom Tucker | 356d0a1 | 2008-05-01 11:25:02 -0500 | [diff] [blame] | 1150 | |
| 1151 | /* Warn if we leaked a resource or under-referenced */ |
| 1152 | WARN_ON(atomic_read(&rdma->sc_ctxt_used) != 0); |
Tom Tucker | 87295b6 | 2008-05-28 13:17:44 -0500 | [diff] [blame] | 1153 | WARN_ON(atomic_read(&rdma->sc_dma_used) != 0); |
Tom Tucker | 356d0a1 | 2008-05-01 11:25:02 -0500 | [diff] [blame] | 1154 | |
Tom Tucker | 64be8608 | 2008-10-06 14:45:18 -0500 | [diff] [blame] | 1155 | /* De-allocate fastreg mr */ |
| 1156 | rdma_dealloc_frmr_q(rdma); |
| 1157 | |
Tom Tucker | 1711386 | 2008-05-01 11:13:50 -0500 | [diff] [blame] | 1158 | /* Destroy the QP if present (not a listener) */ |
| 1159 | if (rdma->sc_qp && !IS_ERR(rdma->sc_qp)) |
| 1160 | ib_destroy_qp(rdma->sc_qp); |
| 1161 | |
Tom Tucker | c48cbb4 | 2008-03-11 14:31:39 -0400 | [diff] [blame] | 1162 | if (rdma->sc_sq_cq && !IS_ERR(rdma->sc_sq_cq)) |
| 1163 | ib_destroy_cq(rdma->sc_sq_cq); |
| 1164 | |
| 1165 | if (rdma->sc_rq_cq && !IS_ERR(rdma->sc_rq_cq)) |
| 1166 | ib_destroy_cq(rdma->sc_rq_cq); |
| 1167 | |
| 1168 | if (rdma->sc_phys_mr && !IS_ERR(rdma->sc_phys_mr)) |
| 1169 | ib_dereg_mr(rdma->sc_phys_mr); |
| 1170 | |
| 1171 | if (rdma->sc_pd && !IS_ERR(rdma->sc_pd)) |
| 1172 | ib_dealloc_pd(rdma->sc_pd); |
| 1173 | |
Tom Tucker | 356d0a1 | 2008-05-01 11:25:02 -0500 | [diff] [blame] | 1174 | /* Destroy the CM ID */ |
| 1175 | rdma_destroy_id(rdma->sc_cm_id); |
| 1176 | |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1177 | kfree(rdma); |
| 1178 | } |
| 1179 | |
Tom Tucker | 8da91ea | 2008-04-30 22:00:46 -0500 | [diff] [blame] | 1180 | static void svc_rdma_free(struct svc_xprt *xprt) |
| 1181 | { |
| 1182 | struct svcxprt_rdma *rdma = |
| 1183 | container_of(xprt, struct svcxprt_rdma, sc_xprt); |
| 1184 | INIT_WORK(&rdma->sc_work, __svc_rdma_free); |
Tejun Heo | a25e758 | 2010-10-15 17:49:27 +0200 | [diff] [blame] | 1185 | queue_work(svc_rdma_wq, &rdma->sc_work); |
Tom Tucker | 8da91ea | 2008-04-30 22:00:46 -0500 | [diff] [blame] | 1186 | } |
| 1187 | |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1188 | static int svc_rdma_has_wspace(struct svc_xprt *xprt) |
| 1189 | { |
| 1190 | struct svcxprt_rdma *rdma = |
| 1191 | container_of(xprt, struct svcxprt_rdma, sc_xprt); |
| 1192 | |
| 1193 | /* |
| 1194 | * If there are fewer SQ WR available than required to send a |
| 1195 | * simple response, return false. |
| 1196 | */ |
| 1197 | if ((rdma->sc_sq_depth - atomic_read(&rdma->sc_sq_count) < 3)) |
| 1198 | return 0; |
| 1199 | |
| 1200 | /* |
| 1201 | * ...or there are already waiters on the SQ, |
| 1202 | * return false. |
| 1203 | */ |
| 1204 | if (waitqueue_active(&rdma->sc_send_wait)) |
| 1205 | return 0; |
| 1206 | |
| 1207 | /* Otherwise return true. */ |
| 1208 | return 1; |
| 1209 | } |
| 1210 | |
Tom Tucker | e118321 | 2008-10-03 15:22:18 -0500 | [diff] [blame] | 1211 | /* |
| 1212 | * Attempt to register the kvec representing the RPC memory with the |
| 1213 | * device. |
| 1214 | * |
| 1215 | * Returns: |
| 1216 | * NULL : The device does not support fastreg or there were no more |
| 1217 | * fastreg mr. |
| 1218 | * frmr : The kvec register request was successfully posted. |
| 1219 | * <0 : An error was encountered attempting to register the kvec. |
| 1220 | */ |
| 1221 | int svc_rdma_fastreg(struct svcxprt_rdma *xprt, |
| 1222 | struct svc_rdma_fastreg_mr *frmr) |
| 1223 | { |
| 1224 | struct ib_send_wr fastreg_wr; |
| 1225 | u8 key; |
| 1226 | |
| 1227 | /* Bump the key */ |
| 1228 | key = (u8)(frmr->mr->lkey & 0x000000FF); |
| 1229 | ib_update_fast_reg_key(frmr->mr, ++key); |
| 1230 | |
| 1231 | /* Prepare FASTREG WR */ |
| 1232 | memset(&fastreg_wr, 0, sizeof fastreg_wr); |
| 1233 | fastreg_wr.opcode = IB_WR_FAST_REG_MR; |
| 1234 | fastreg_wr.send_flags = IB_SEND_SIGNALED; |
| 1235 | fastreg_wr.wr.fast_reg.iova_start = (unsigned long)frmr->kva; |
| 1236 | fastreg_wr.wr.fast_reg.page_list = frmr->page_list; |
| 1237 | fastreg_wr.wr.fast_reg.page_list_len = frmr->page_list_len; |
| 1238 | fastreg_wr.wr.fast_reg.page_shift = PAGE_SHIFT; |
| 1239 | fastreg_wr.wr.fast_reg.length = frmr->map_len; |
| 1240 | fastreg_wr.wr.fast_reg.access_flags = frmr->access_flags; |
| 1241 | fastreg_wr.wr.fast_reg.rkey = frmr->mr->lkey; |
| 1242 | return svc_rdma_send(xprt, &fastreg_wr); |
| 1243 | } |
| 1244 | |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1245 | int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr) |
| 1246 | { |
Tom Tucker | 5b180a9 | 2008-08-11 14:10:19 -0500 | [diff] [blame] | 1247 | struct ib_send_wr *bad_wr, *n_wr; |
| 1248 | int wr_count; |
| 1249 | int i; |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1250 | int ret; |
| 1251 | |
| 1252 | if (test_bit(XPT_CLOSE, &xprt->sc_xprt.xpt_flags)) |
Tom Tucker | 9d6347a | 2008-04-25 15:51:27 -0500 | [diff] [blame] | 1253 | return -ENOTCONN; |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1254 | |
| 1255 | BUG_ON(wr->send_flags != IB_SEND_SIGNALED); |
Tom Tucker | 5b180a9 | 2008-08-11 14:10:19 -0500 | [diff] [blame] | 1256 | wr_count = 1; |
| 1257 | for (n_wr = wr->next; n_wr; n_wr = n_wr->next) |
| 1258 | wr_count++; |
| 1259 | |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1260 | /* If the SQ is full, wait until an SQ entry is available */ |
| 1261 | while (1) { |
| 1262 | spin_lock_bh(&xprt->sc_lock); |
Tom Tucker | 5b180a9 | 2008-08-11 14:10:19 -0500 | [diff] [blame] | 1263 | if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) { |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1264 | spin_unlock_bh(&xprt->sc_lock); |
| 1265 | atomic_inc(&rdma_stat_sq_starve); |
Tom Tucker | dbcd00e | 2008-05-06 11:33:11 -0500 | [diff] [blame] | 1266 | |
| 1267 | /* See if we can opportunistically reap SQ WR to make room */ |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1268 | sq_cq_reap(xprt); |
| 1269 | |
| 1270 | /* Wait until SQ WR available if SQ still full */ |
| 1271 | wait_event(xprt->sc_send_wait, |
| 1272 | atomic_read(&xprt->sc_sq_count) < |
| 1273 | xprt->sc_sq_depth); |
Tom Tucker | 830bb59 | 2008-03-11 12:44:27 -0500 | [diff] [blame] | 1274 | if (test_bit(XPT_CLOSE, &xprt->sc_xprt.xpt_flags)) |
Tom Tucker | b432e6b | 2010-10-12 15:33:52 -0500 | [diff] [blame] | 1275 | return -ENOTCONN; |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1276 | continue; |
| 1277 | } |
Tom Tucker | 5b180a9 | 2008-08-11 14:10:19 -0500 | [diff] [blame] | 1278 | /* Take a transport ref for each WR posted */ |
| 1279 | for (i = 0; i < wr_count; i++) |
| 1280 | svc_xprt_get(&xprt->sc_xprt); |
| 1281 | |
| 1282 | /* Bump used SQ WR count and post */ |
| 1283 | atomic_add(wr_count, &xprt->sc_sq_count); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1284 | ret = ib_post_send(xprt->sc_qp, wr, &bad_wr); |
Tom Tucker | 5b180a9 | 2008-08-11 14:10:19 -0500 | [diff] [blame] | 1285 | if (ret) { |
| 1286 | set_bit(XPT_CLOSE, &xprt->sc_xprt.xpt_flags); |
| 1287 | atomic_sub(wr_count, &xprt->sc_sq_count); |
| 1288 | for (i = 0; i < wr_count; i ++) |
| 1289 | svc_xprt_put(&xprt->sc_xprt); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1290 | dprintk("svcrdma: failed to post SQ WR rc=%d, " |
| 1291 | "sc_sq_count=%d, sc_sq_depth=%d\n", |
| 1292 | ret, atomic_read(&xprt->sc_sq_count), |
| 1293 | xprt->sc_sq_depth); |
Tom Tucker | 0905c0f | 2008-05-01 10:49:03 -0500 | [diff] [blame] | 1294 | } |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1295 | spin_unlock_bh(&xprt->sc_lock); |
Tom Tucker | 5b180a9 | 2008-08-11 14:10:19 -0500 | [diff] [blame] | 1296 | if (ret) |
| 1297 | wake_up(&xprt->sc_send_wait); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1298 | break; |
| 1299 | } |
| 1300 | return ret; |
| 1301 | } |
| 1302 | |
Tom Tucker | 008fdbc | 2008-05-07 15:47:42 -0500 | [diff] [blame] | 1303 | void svc_rdma_send_error(struct svcxprt_rdma *xprt, struct rpcrdma_msg *rmsgp, |
| 1304 | enum rpcrdma_errcode err) |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1305 | { |
| 1306 | struct ib_send_wr err_wr; |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1307 | struct page *p; |
| 1308 | struct svc_rdma_op_ctxt *ctxt; |
| 1309 | u32 *va; |
| 1310 | int length; |
| 1311 | int ret; |
| 1312 | |
| 1313 | p = svc_rdma_get_page(); |
| 1314 | va = page_address(p); |
| 1315 | |
| 1316 | /* XDR encode error */ |
| 1317 | length = svc_rdma_xdr_encode_error(xprt, rmsgp, err, va); |
| 1318 | |
Tom Tucker | 4a84386 | 2010-10-12 15:33:57 -0500 | [diff] [blame] | 1319 | ctxt = svc_rdma_get_context(xprt); |
| 1320 | ctxt->direction = DMA_FROM_DEVICE; |
| 1321 | ctxt->count = 1; |
| 1322 | ctxt->pages[0] = p; |
| 1323 | |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1324 | /* Prepare SGE for local address */ |
Tom Tucker | 4a84386 | 2010-10-12 15:33:57 -0500 | [diff] [blame] | 1325 | ctxt->sge[0].addr = ib_dma_map_page(xprt->sc_cm_id->device, |
| 1326 | p, 0, length, DMA_FROM_DEVICE); |
| 1327 | if (ib_dma_mapping_error(xprt->sc_cm_id->device, ctxt->sge[0].addr)) { |
Tom Tucker | 04911b5 | 2008-08-11 15:14:53 -0500 | [diff] [blame] | 1328 | put_page(p); |
Jesper Juhl | a5e5026 | 2011-01-22 21:40:20 +0000 | [diff] [blame] | 1329 | svc_rdma_put_context(ctxt, 1); |
Tom Tucker | 04911b5 | 2008-08-11 15:14:53 -0500 | [diff] [blame] | 1330 | return; |
| 1331 | } |
| 1332 | atomic_inc(&xprt->sc_dma_used); |
Tom Tucker | 4a84386 | 2010-10-12 15:33:57 -0500 | [diff] [blame] | 1333 | ctxt->sge[0].lkey = xprt->sc_dma_lkey; |
| 1334 | ctxt->sge[0].length = length; |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1335 | |
| 1336 | /* Prepare SEND WR */ |
| 1337 | memset(&err_wr, 0, sizeof err_wr); |
| 1338 | ctxt->wr_op = IB_WR_SEND; |
| 1339 | err_wr.wr_id = (unsigned long)ctxt; |
Tom Tucker | 4a84386 | 2010-10-12 15:33:57 -0500 | [diff] [blame] | 1340 | err_wr.sg_list = ctxt->sge; |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1341 | err_wr.num_sge = 1; |
| 1342 | err_wr.opcode = IB_WR_SEND; |
| 1343 | err_wr.send_flags = IB_SEND_SIGNALED; |
| 1344 | |
| 1345 | /* Post It */ |
| 1346 | ret = svc_rdma_send(xprt, &err_wr); |
| 1347 | if (ret) { |
Tom Tucker | 008fdbc | 2008-05-07 15:47:42 -0500 | [diff] [blame] | 1348 | dprintk("svcrdma: Error %d posting send for protocol error\n", |
| 1349 | ret); |
Tom Tucker | 4a84386 | 2010-10-12 15:33:57 -0500 | [diff] [blame] | 1350 | svc_rdma_unmap_dma(ctxt); |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1351 | svc_rdma_put_context(ctxt, 1); |
| 1352 | } |
Tom Tucker | 377f9b2 | 2007-12-12 16:13:21 -0600 | [diff] [blame] | 1353 | } |