From patchwork Tue Feb 22 11:50:16 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Walukiewicz, Miroslaw" X-Patchwork-Id: 580181 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p1MBmhwI029123 for ; Tue, 22 Feb 2011 11:50:22 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754028Ab1BVLuV (ORCPT ); Tue, 22 Feb 2011 06:50:21 -0500 Received: from mga01.intel.com ([192.55.52.88]:63880 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751860Ab1BVLuU (ORCPT ); Tue, 22 Feb 2011 06:50:20 -0500 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 22 Feb 2011 03:50:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.62,206,1297065600"; d="scan'208";a="660207952" Received: from cmsutil001.isw.intel.com ([10.237.237.10]) by fmsmga002.fm.intel.com with ESMTP; 22 Feb 2011 03:50:19 -0800 Received: from gkslx010.igk.intel.com (gkslx010.igk.intel.com [172.28.168.161]) by cmsutil001.isw.intel.com (8.12.11.20060308/8.12.11/MailSET/Hub) with ESMTP id p1MBoInl027769; Tue, 22 Feb 2011 11:50:18 GMT Received: from gkslx010.igk.intel.com (localhost [127.0.0.1]) by gkslx010.igk.intel.com with ESMTP id p1MBoGkO018955; Tue, 22 Feb 2011 12:50:17 +0100 Subject: [PATCH] RDMA/core: Optimized path for kernel post_send/post_recv To: roland@kernel.org From: miroslaw.walukiewicz@intel.com Cc: linux-rdma@vger.kernel.org Date: Tue, 22 Feb 2011 12:50:16 +0100 Message-ID: <20110222114659.18362.32423.stgit@gkslx010.igk.intel.com> User-Agent: StGit/0.15 MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 22 Feb 2011 11:50:22 +0000 (UTC) diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index c426992..ba6655c 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c @@ -299,6 +299,7 @@ ssize_t ib_uverbs_get_context(struct ib_uverbs_file *file, INIT_LIST_HEAD(&ucontext->srq_list); INIT_LIST_HEAD(&ucontext->ah_list); ucontext->closing = 0; + ucontext->use_shpage_for_rxtx = 0; resp.num_comp_vectors = file->device->num_comp_vectors; @@ -1448,15 +1449,31 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file, if (cmd.wqe_size < sizeof (struct ib_uverbs_send_wr)) return -EINVAL; + qp = idr_read_qp(cmd.qp_handle, file->ucontext); + if (!qp) + goto out_raw_qp; + + if (file->ucontext->use_shpage_for_rxtx) { + /* pass NULL pointers as the information about */ + /* buffers is passed using endor defined shared page */ + resp.bad_wr = 0; + ret = qp->device->post_send(qp, NULL, NULL); + if (ret) + resp.bad_wr = cmd.wr_count; + + if (copy_to_user((void __user *) (unsigned long) + cmd.response, + &resp, + sizeof resp)) + ret = -EFAULT; + put_qp_read(qp); + goto out_raw_qp; + } user_wr = kmalloc(cmd.wqe_size, GFP_KERNEL); if (!user_wr) return -ENOMEM; - qp = idr_read_qp(cmd.qp_handle, file->ucontext); - if (!qp) - goto out; - is_ud = qp->qp_type == IB_QPT_UD; sg_ind = 0; last = NULL; @@ -1576,9 +1593,8 @@ out_put: wr = next; } -out: kfree(user_wr); - +out_raw_qp: return ret ? ret : in_len; } @@ -1680,16 +1696,33 @@ ssize_t ib_uverbs_post_recv(struct ib_uverbs_file *file, if (copy_from_user(&cmd, buf, sizeof cmd)) return -EFAULT; + qp = idr_read_qp(cmd.qp_handle, file->ucontext); + if (!qp) + goto out_raw_qp; + + if (file->ucontext->use_shpage_for_rxtx) { + resp.bad_wr = 0; + /* pass NULL pointers as the information about */ + /* buffers is passed using endor defined shared page */ + ret = qp->device->post_recv(qp, NULL, NULL); + if (ret) + resp.bad_wr = cmd.wr_count; + + if (copy_to_user((void __user *) (unsigned long) + cmd.response, + &resp, + sizeof resp)) + ret = -EFAULT; + put_qp_read(qp); + goto out_raw_qp; + } + wr = ib_uverbs_unmarshall_recv(buf + sizeof cmd, in_len - sizeof cmd, cmd.wr_count, cmd.sge_count, cmd.wqe_size); if (IS_ERR(wr)) return PTR_ERR(wr); - qp = idr_read_qp(cmd.qp_handle, file->ucontext); - if (!qp) - goto out; - resp.bad_wr = 0; ret = qp->device->post_recv(qp, wr, &bad_wr); @@ -1706,13 +1739,13 @@ ssize_t ib_uverbs_post_recv(struct ib_uverbs_file *file, &resp, sizeof resp)) ret = -EFAULT; -out: while (wr) { next = wr->next; kfree(wr); wr = next; } +out_raw_qp: return ret ? ret : in_len; } diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 55cd0a0..ab31c03 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -831,6 +831,7 @@ struct ib_ucontext { struct list_head srq_list; struct list_head ah_list; int closing; + int use_shpage_for_rxtx; }; struct ib_uobject {