From patchwork Thu May 17 10:39:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 10406309 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 BB9B060230 for ; Thu, 17 May 2018 10:40:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A6C1828A8B for ; Thu, 17 May 2018 10:40:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A458C28A99; Thu, 17 May 2018 10:40:07 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, 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 F214428A8B for ; Thu, 17 May 2018 10:40:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751907AbeEQKkE (ORCPT ); Thu, 17 May 2018 06:40:04 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:44992 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751520AbeEQKkD (ORCPT ); Thu, 17 May 2018 06:40:03 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yishaih@mellanox.com) with ESMTPS (AES256-SHA encrypted); 17 May 2018 13:41:47 +0300 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 w4HAdu11002324; Thu, 17 May 2018 13:39:56 +0300 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 w4HAduPi032386; Thu, 17 May 2018 13:39:56 +0300 Received: (from yishaih@localhost) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8/Submit) id w4HAduBK032385; Thu, 17 May 2018 13:39:56 +0300 From: Yishai Hadas To: linux-rdma@vger.kernel.org Cc: yishaih@mellanox.com, raeds@mellanox.com Subject: [PATCH rdma-core 02/11] verbs: Use ccan bitmap instead of u64 bit mask for unsupported IOCTLs Date: Thu, 17 May 2018 13:39:28 +0300 Message-Id: <1526553577-32273-3-git-send-email-yishaih@mellanox.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1526553577-32273-1-git-send-email-yishaih@mellanox.com> References: <1526553577-32273-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: Raed Salem Using ccan bitmap to enlarge IOCTL unsupported mask beyond 64 bit. Signed-off-by: Raed Salem Signed-off-by: Yishai Hadas --- libibverbs/cmd_fallback.c | 10 +++------- libibverbs/ibverbs.h | 5 ++++- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/libibverbs/cmd_fallback.c b/libibverbs/cmd_fallback.c index a829088..7caa28d 100644 --- a/libibverbs/cmd_fallback.c +++ b/libibverbs/cmd_fallback.c @@ -84,14 +84,10 @@ enum write_fallback _execute_ioctl_fallback(struct ibv_context *ctx, struct ibv_command_buffer *cmdb, int *ret) { - uint64_t cmd_val = 1ULL << cmd_bit; - - BUILD_ASSERT(sizeof(struct verbs_context_ops) / sizeof(void *) < 64); - struct verbs_ex_private *priv = container_of(ctx, struct verbs_context, context)->priv; - if (priv->unsupported_ioctls & cmd_val) + if (bitmap_test_bit(priv->unsupported_ioctls, cmd_bit)) return _check_legacy(cmdb, ret); *ret = execute_ioctl(ctx, cmdb); @@ -101,7 +97,7 @@ enum write_fallback _execute_ioctl_fallback(struct ibv_context *ctx, if (*ret == ENOTTY) { /* ENOTTY means the ioctl framework is entirely absent */ - priv->unsupported_ioctls = UINT64_MAX; + bitmap_fill(priv->unsupported_ioctls, VERBS_OPS_NUM); return _check_legacy(cmdb, ret); } @@ -110,7 +106,7 @@ enum write_fallback _execute_ioctl_fallback(struct ibv_context *ctx, * EPROTONOSUPPORT means we have the ioctl framework but this * specific method is not supported */ - priv->unsupported_ioctls |= cmd_val; + bitmap_set_bit(priv->unsupported_ioctls, cmd_bit); return _check_legacy(cmdb, ret); } diff --git a/libibverbs/ibverbs.h b/libibverbs/ibverbs.h index b493808..4da9282 100644 --- a/libibverbs/ibverbs.h +++ b/libibverbs/ibverbs.h @@ -40,9 +40,12 @@ #include +#include + #define INIT __attribute__((constructor)) #define PFX "libibverbs: " +#define VERBS_OPS_NUM (sizeof(struct verbs_context_ops) / sizeof(void *)) struct ibv_abi_compat_v2 { struct ibv_comp_channel channel; @@ -61,7 +64,7 @@ struct verbs_ex_private { struct ibv_cq_ex *(*create_cq_ex)(struct ibv_context *context, struct ibv_cq_init_attr_ex *init_attr); - uint64_t unsupported_ioctls; + BITMAP_DECLARE(unsupported_ioctls, VERBS_OPS_NUM); uint32_t driver_id; };