From patchwork Wed Mar 21 18:09:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 10299979 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 1B430600F6 for ; Wed, 21 Mar 2018 18:10:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 07380298C1 for ; Wed, 21 Mar 2018 18:10:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EDD13298E7; Wed, 21 Mar 2018 18:10:30 +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, UNPARSEABLE_RELAY 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 65F3C298E6 for ; Wed, 21 Mar 2018 18:10:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752407AbeCUSK1 (ORCPT ); Wed, 21 Mar 2018 14:10:27 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:57447 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752415AbeCUSK0 (ORCPT ); Wed, 21 Mar 2018 14:10:26 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yishaih@mellanox.com) with ESMTPS (AES256-SHA encrypted); 21 Mar 2018 20:11:07 +0200 Received: from vnc17.mtl.labs.mlnx (vnc17.mtl.labs.mlnx [10.7.2.17]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id w2LIAJPx014330; Wed, 21 Mar 2018 20:10:19 +0200 Received: from vnc17.mtl.labs.mlnx (vnc17.mtl.labs.mlnx [127.0.0.1]) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8) with ESMTP id w2LIAJgB007756; Wed, 21 Mar 2018 20:10:19 +0200 Received: (from yishaih@localhost) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8/Submit) id w2LIAJPq007754; Wed, 21 Mar 2018 20:10:19 +0200 From: Yishai Hadas To: linux-rdma@vger.kernel.org Cc: yishaih@mellanox.com, matanb@mellanox.com, jgg@mellanox.com, majd@mellanox.com Subject: [PATCH rdma-core 01/11] verbs: Add enum attribute type to the ioctl infrastructure Date: Wed, 21 Mar 2018 20:09:50 +0200 Message-Id: <1521655800-7287-2-git-send-email-yishaih@mellanox.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1521655800-7287-1-git-send-email-yishaih@mellanox.com> References: <1521655800-7287-1-git-send-email-yishaih@mellanox.com> 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: Matan Barak Methods sometimes need to get one attribute out of a group of pre-defined attributes. This is an enum-like behavior. Since this is a common requirement, we add a new ENUM attribute to the generic ioctl layer in the kernel. This attribute is embedded in methods, like any other attributes we currently have. We align the user-space code with the respected changes in the kernel. Signed-off-by: Matan Barak Signed-off-by: Yishai Hadas --- kernel-headers/rdma/rdma_user_ioctl_cmds.h | 8 +++++++- libibverbs/cmd_ioctl.h | 12 ++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/kernel-headers/rdma/rdma_user_ioctl_cmds.h b/kernel-headers/rdma/rdma_user_ioctl_cmds.h index 40063cf..1da5a1e 100644 --- a/kernel-headers/rdma/rdma_user_ioctl_cmds.h +++ b/kernel-headers/rdma/rdma_user_ioctl_cmds.h @@ -55,7 +55,13 @@ struct ib_uverbs_attr { __u16 attr_id; /* command specific type attribute */ __u16 len; /* only for pointers */ __u16 flags; /* combination of UVERBS_ATTR_F_XXXX */ - __u16 reserved; + union { + struct { + __u8 elem_id; + __u8 reserved; + } enum_data; + __u16 reserved; + } attr_data; __aligned_u64 data; /* ptr to command, inline data or idr/fd */ }; diff --git a/libibverbs/cmd_ioctl.h b/libibverbs/cmd_ioctl.h index 2b6d12a..94814c1 100644 --- a/libibverbs/cmd_ioctl.h +++ b/libibverbs/cmd_ioctl.h @@ -346,4 +346,16 @@ static inline size_t __check_divide(size_t val, unsigned int div) return val / div; } +static inline struct ib_uverbs_attr * +fill_attr_in_enum(struct ibv_command_buffer *cmd, uint16_t attr_id, + uint8_t elem_id, const void *data, size_t len) +{ + struct ib_uverbs_attr *attr; + + attr = fill_attr_in(cmd, attr_id, data, len); + attr->attr_data.enum_data.elem_id = elem_id; + + return attr; +} + #endif