From patchwork Tue May 24 14:35:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 9133769 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A658F607D3 for ; Tue, 24 May 2016 14:35:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A3FE28117 for ; Tue, 24 May 2016 14:35:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F2432827A; Tue, 24 May 2016 14:35:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 374AF28117 for ; Tue, 24 May 2016 14:35:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755438AbcEXOfs (ORCPT ); Tue, 24 May 2016 10:35:48 -0400 Received: from mail.kernel.org ([198.145.29.136]:43028 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752991AbcEXOfs (ORCPT ); Tue, 24 May 2016 10:35:48 -0400 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 805FA203A1; Tue, 24 May 2016 14:35:46 +0000 (UTC) Received: from localhost (unknown [213.57.247.249]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2985520351; Tue, 24 May 2016 14:35:44 +0000 (UTC) From: Leon Romanovsky To: dledford@redhat.com Cc: linux-rdma@vger.kernel.org, Leon Romanovsky , Matan Barak , Haggai Eran Subject: [RFC ABI 4/8] IB/core: Add DIRECT ioctl call to vendor Date: Tue, 24 May 2016 17:35:22 +0300 Message-Id: <1464100526-31730-5-git-send-email-leonro@mellanox.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1464100526-31730-1-git-send-email-leonro@mellanox.com> References: <1464100526-31730-1-git-send-email-leonro@mellanox.com> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Introduce a new RDMA IOCTL command, which will be visible to consumers, which would like to execute commands straight on the vendor's driver. It bypasses IB core logic and is intended for vendor specific channel operations. Signed-off-by: Matan Barak Signed-off-by: Leon Romanovsky Signed-off-by: Haggai Eran --- drivers/infiniband/core/uverbs_main.c | 33 +++++++++++++++++++++++++++++++++ include/rdma/ib_verbs.h | 2 ++ include/uapi/rdma/ib_user_ioctl.h | 5 +++++ 3 files changed, 40 insertions(+) diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c index 42fbb6d..68cf1fd 100644 --- a/drivers/infiniband/core/uverbs_main.c +++ b/drivers/infiniband/core/uverbs_main.c @@ -850,6 +850,37 @@ out: return ret; } +static long ib_uverbs_ioctl(struct file *filp, unsigned int cmd, + unsigned long arg) +{ + struct ib_uverbs_file *file = filp->private_data; + struct ib_device *ib_dev; + int srcu_key; + + if (WARN_ON_ONCE(!ib_safe_file_access(filp))) + return -EACCES; + + if (cmd == IB_IOCTL_DIRECT) { + long ret = 0; + + srcu_key = srcu_read_lock(&file->device->disassociate_srcu); + ib_dev = srcu_dereference(file->device->ib_dev, + &file->device->disassociate_srcu); + if (!ib_dev) { + srcu_read_unlock(&file->device->disassociate_srcu, srcu_key); + return -EIO; + } + + if (ib_dev->direct_fn) + ret = ib_dev->direct_fn(filp, arg); + + srcu_read_unlock(&file->device->disassociate_srcu, srcu_key); + return ret; + } + + return -ENOIOCTLCMD; +} + static int ib_uverbs_mmap(struct file *filp, struct vm_area_struct *vma) { struct ib_uverbs_file *file = filp->private_data; @@ -985,6 +1016,7 @@ static const struct file_operations uverbs_fops = { .open = ib_uverbs_open, .release = ib_uverbs_close, .llseek = no_llseek, + .unlocked_ioctl = ib_uverbs_ioctl, }; static const struct file_operations uverbs_mmap_fops = { @@ -994,6 +1026,7 @@ static const struct file_operations uverbs_mmap_fops = { .open = ib_uverbs_open, .release = ib_uverbs_close, .llseek = no_llseek, + .unlocked_ioctl = ib_uverbs_ioctl, }; static struct ib_client uverbs_client = { diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index fc0320c..1904c02 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -1707,6 +1707,8 @@ struct ib_device { struct iw_cm_verbs *iwcm; + long (*direct_fn)(struct file *filp, + unsigned long arg); int (*get_protocol_stats)(struct ib_device *device, union rdma_protocol_stats *stats); int (*query_device)(struct ib_device *device, diff --git a/include/uapi/rdma/ib_user_ioctl.h b/include/uapi/rdma/ib_user_ioctl.h index d1928dea..f17e51a 100644 --- a/include/uapi/rdma/ib_user_ioctl.h +++ b/include/uapi/rdma/ib_user_ioctl.h @@ -38,6 +38,11 @@ #define IB_IOCTL_MAGIC 0x1b +#define IB_CMD_DIRECT 0x2 + +#define IB_IOCTL_DIRECT \ + _IOWR(IB_IOCTL_MAGIC, IB_CMD_DIRECT, unsigned long) + /* Legacy part * !!!! NOTE: It uses the same command index as VERBS */