From patchwork Sun Feb 14 15:07:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 8302191 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id F3AE29F38B for ; Sun, 14 Feb 2016 15:08:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0B14920398 for ; Sun, 14 Feb 2016 15:08:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1EAD9203C2 for ; Sun, 14 Feb 2016 15:08:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751250AbcBNPI0 (ORCPT ); Sun, 14 Feb 2016 10:08:26 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:34753 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751399AbcBNPIL (ORCPT ); Sun, 14 Feb 2016 10:08:11 -0500 Received: by mail-wm0-f68.google.com with SMTP id b205so4192007wmb.1 for ; Sun, 14 Feb 2016 07:08:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leon-nu.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=n8/+pYuyNZ7sYA8V2KJoxq4YzhU5CMNBCJFoEQ32u7s=; b=yAsOY6DAa2H6YhLlO3m9Chxlr+32LDx6RAdS/pnYPlKCwW3P9FDJhzj0lmDg/2KHMx xoD0RpbLuGtSLMP+iQvWnRMLWoJsRrkdCnrw1CVAxp0H4/ggJPZNDG9vimsv1OtNxbAl WKGc10FwhV/zLdjafbRkJDUHU7e89+q62iHonXsr82l9Gdz+Sz+stVOqt1TYZ3knWxB4 nI4kk2uWGpB4gUSVsRL7etRoY/WLXOlUkwq/bwnsGF+my9dh9oqaNULFXcZFkZ8K0EaZ bmnWuwmswgvzmp6nqOrQxGg3p1du217ZCKsZOq+mjoxwEgDp0BhB0rTVMWUezf17ZAwC uUzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=n8/+pYuyNZ7sYA8V2KJoxq4YzhU5CMNBCJFoEQ32u7s=; b=jx/dvh/OJZ7d0Jr+/LCUjVMzWjIL6TLXqNkXHMk7r9OcnvulNVhjOQYoAdTBkh8//v dEXv19AuuhZ/JgEKyc1ols2ltqTWnqg46gJ8WJ5/JJaGWQH/pbJelT1TWEQJ7WDmgnL6 wPtl1Pk9CZmCz6XYMF/I90CFZgAUlN5Wjf9bC2V1Ihl6pEiSrkeoWaHrMvetO4Wom9/7 IPysEJprEUm9MpC4RTdogzOitEXbJ38S8z9ixYL184WyiTb4UAz2dGG+CjTgBedlLOn2 UWLVa6G00CH+GtvznB8gQchsy9bAsVFiHSiCr2tQI/psZhwauDQC0+ID2M5zJEUsCVPy +N3g== X-Gm-Message-State: AG10YOSKgEE+TqwyVlAfsXguRrXGLn9X2YxLioZZcdGLg0lu7UzVH+omNdC5d/Ehtced/g== X-Received: by 10.28.238.144 with SMTP id j16mr7464884wmi.43.1455462489849; Sun, 14 Feb 2016 07:08:09 -0800 (PST) Received: from localhost ([213.57.247.249]) by smtp.gmail.com with ESMTPSA id c185sm11406084wma.5.2016.02.14.07.08.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Feb 2016 07:08:08 -0800 (PST) From: Leon Romanovsky To: dledford@redhat.com Cc: linux-rdma@vger.kernel.org, Eli Cohen , Leon Romanovsky Subject: [PATCH rdma-next 2/3] IB/core: IB/core: Allow legacy verbs through extended interfaces Date: Sun, 14 Feb 2016 17:07:48 +0200 Message-Id: <1455462469-9124-3-git-send-email-leon@leon.nu> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1455462469-9124-1-git-send-email-leon@leon.nu> References: <1455462469-9124-1-git-send-email-leon@leon.nu> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Eli Cohen When an extended verbs is an extension to a legacy verb, the original functionality is preserved. Hence we do not require each hardware driver to set the extended capability. This will allow to use the extended verb in its simple form with drivers that do not support the extended capability. Signed-off-by: Eli Cohen Signed-off-by: Leon Romanovsky --- drivers/infiniband/core/uverbs_main.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c index 08f1a7b..20f0049 100644 --- a/drivers/infiniband/core/uverbs_main.c +++ b/drivers/infiniband/core/uverbs_main.c @@ -683,6 +683,21 @@ out: return ev_file; } +static int verify_command_mask(struct ib_device *ib_dev, __u32 command) +{ + u64 mask; + + if (command <= IB_USER_VERBS_CMD_OPEN_QP) + mask = ib_dev->uverbs_cmd_mask; + else + mask = ib_dev->uverbs_ex_cmd_mask; + + if (mask & ((u64)1 << command)) + return 0; + + return -1; +} + static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf, size_t count, loff_t *pos) { @@ -715,6 +730,10 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf, } command = hdr.command & IB_USER_VERBS_CMD_COMMAND_MASK; + if (verify_command_mask(ib_dev, command)) { + ret = -EOPNOTSUPP; + goto out; + } flags = (hdr.command & IB_USER_VERBS_CMD_FLAGS_MASK) >> IB_USER_VERBS_CMD_FLAGS_SHIFT; @@ -732,11 +751,6 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf, goto out; } - if (!(ib_dev->uverbs_cmd_mask & (1ull << command))) { - ret = -ENOSYS; - goto out; - } - if (hdr.in_words * 4 != count) { ret = -EINVAL; goto out; @@ -764,11 +778,6 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf, goto out; } - if (!(ib_dev->uverbs_ex_cmd_mask & (1ull << command))) { - ret = -ENOSYS; - goto out; - } - if (count < (sizeof(hdr) + sizeof(ex_hdr))) { ret = -EINVAL; goto out;