From patchwork Sun Nov 27 14:51:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 9448813 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 562756071A for ; Sun, 27 Nov 2016 14:52:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 50EA627BFF for ; Sun, 27 Nov 2016 14:52:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4303927C0B; Sun, 27 Nov 2016 14:52:18 +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 D5BC026785 for ; Sun, 27 Nov 2016 14:52:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752132AbcK0OwL (ORCPT ); Sun, 27 Nov 2016 09:52:11 -0500 Received: from mail.kernel.org ([198.145.29.136]:47396 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752126AbcK0OwL (ORCPT ); Sun, 27 Nov 2016 09:52:11 -0500 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 67D89202A1; Sun, 27 Nov 2016 14:52:04 +0000 (UTC) Received: from localhost (unknown [193.47.165.251]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BFA6A20274; Sun, 27 Nov 2016 14:52:02 +0000 (UTC) From: Leon Romanovsky To: dledford@redhat.com Cc: linux-rdma@vger.kernel.org, Steve Wise , Mike Marciniszyn , Dennis Dalessandro , Lijun Ou , "Wei Hu(Xavier)" , Faisal Latif , Yishai Hadas , Selvin Xavier , Devesh Sharma , Mitesh Ahuja , Christian Benvenuti , Dave Goodell , Moni Shoua , Or Gerlitz Subject: [PATCH rdma-next 07/10] IB/uverbs: Propagate supported QP types to user-space Date: Sun, 27 Nov 2016 16:51:33 +0200 Message-Id: <1480258296-27032-8-git-send-email-leon@kernel.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1480258296-27032-1-git-send-email-leon@kernel.org> References: <1480258296-27032-1-git-send-email-leon@kernel.org> 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 From: Or Gerlitz Propagate supported qp types to user-space when they issue a query port call. From user-space point of view, zero means that the query is not supported, under the reasoning that it doesn't make sense to have user-space devices that don't support any qp type. Note that this will only happen when they run over older kernels. Make sure to filter out qp types which are not supported for user-space (SMI, GSI, etc). Signed-off-by: Or Gerlitz Reviewed-by: Matan Barak Signed-off-by: Leon Romanovsky --- drivers/infiniband/core/uverbs_cmd.c | 2 ++ include/uapi/rdma/ib_user_verbs.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index cb3f515a..1c386bc 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c @@ -526,6 +526,8 @@ ssize_t ib_uverbs_query_port(struct ib_uverbs_file *file, resp.phys_state = attr.phys_state; resp.link_layer = rdma_port_get_link_layer(ib_dev, cmd.port_num); + /* don't expose to user-space QPTs they don't know */ + resp.qp_type_cap = attr.qp_type_cap & ~(BIT(IB_QPT_SMI) | BIT(IB_QPT_GSI)); if (copy_to_user((void __user *) (unsigned long) cmd.response, &resp, sizeof resp)) diff --git a/include/uapi/rdma/ib_user_verbs.h b/include/uapi/rdma/ib_user_verbs.h index 25225eb..a50604f 100644 --- a/include/uapi/rdma/ib_user_verbs.h +++ b/include/uapi/rdma/ib_user_verbs.h @@ -276,7 +276,7 @@ struct ib_uverbs_query_port_resp { __u8 active_speed; __u8 phys_state; __u8 link_layer; - __u8 reserved[2]; + __u16 qp_type_cap; }; struct ib_uverbs_alloc_pd {