From patchwork Thu Nov 22 23:24:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 10694983 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5791013B5 for ; Thu, 22 Nov 2018 23:24:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 45D6F2BF0F for ; Thu, 22 Nov 2018 23:24:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A3D22C2F0; Thu, 22 Nov 2018 23:24:26 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 8F2FD2C196 for ; Thu, 22 Nov 2018 23:24:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407888AbeKWKGH (ORCPT ); Fri, 23 Nov 2018 05:06:07 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:43949 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2407881AbeKWKGG (ORCPT ); Fri, 23 Nov 2018 05:06:06 -0500 Received: by mail-pl1-f194.google.com with SMTP id gn14so9796612plb.10 for ; Thu, 22 Nov 2018 15:24:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RNaGLromelH47v92nmEft8tiB2pV5fewesSVDn0Bmb4=; b=QhFL58JGNHi4P9f/Z/QZJqjXrCL9oE8Cr1GblHbx5b6EKhZ3nWppYGiH4msAWUWE8k Zoayt5CFHXI7MKl4jIckpwNKVljGv2mrwx5sRNbHvHBddZneoLEpnWLunDwGmc3xqJST Iv1YaB12xaWBVomERpLTrh1N4+aI5pvF9GCh7RXGyE3rLud8mfxcb0MmGXQbqdFpZCpp sSTK4KOZigzoiDXBt/fhdaCfCeQJrg+kvo0Xq912qES1PsXA8e2m6dkf+wxFZm7VPXaA rvNLQuEH7h9UT5WOn0gaQkflE0Lt8rIhfyENI4Bk7vfEAI+uOjowRkLEQsVKOgmsBGks qdLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RNaGLromelH47v92nmEft8tiB2pV5fewesSVDn0Bmb4=; b=Y5c43MMV58fxXs8t1KO8ZoYSJS2KbdcVPvxnbUHnMk/M5O1FOqZwg4wJMyAGbRZnbH 0JT5sJr84gRYoUxkGuhM4xjFEkz2WDfhCqJw4BJO+LGioj7zaZDQiqrwxtwLLTXY6qhT BoqM8paz4EH1lwR9wMd6Ll6zYNmSkwfExOngJkRzp7P/xIpfQTsEcfaOrf0v1N4nSto1 rLNnNPx7qYKsIzbKgyacGx1uor6v/Feetb4+kDLmDsHGvt+iByKunw0p0+E4Vywa159G avlgMVZKiKGzisrraSGuWuFzc3g7wXNfUwK34pQ0WS2GP2PWiXlcvXhFSNkGiyM/dsQT 5WaA== X-Gm-Message-State: AA+aEWa5iJDYPh01J31jz1UPcqIOcm9qFIjwmVx5zutmdoE9EeVlfxgn P1js9v2wYStBMSgjPBR8BsmO/VG8tsI= X-Google-Smtp-Source: AFSGD/WmRHBW6hafmmwvKcuMpvSbJwGRVnbR9ER5hErh/vsvNg5ajYiP45xdWTRV6ZRXrwkN1RKzGg== X-Received: by 2002:a17:902:b118:: with SMTP id q24mr13286718plr.209.1542929063160; Thu, 22 Nov 2018 15:24:23 -0800 (PST) Received: from ziepe.ca (S010614cc2056d97f.ed.shawcable.net. [174.3.196.123]) by smtp.gmail.com with ESMTPSA id v15sm36858094pfn.94.2018.11.22.15.24.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Nov 2018 15:24:19 -0800 (PST) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1gPyKY-0007sh-Ck; Thu, 22 Nov 2018 16:24:18 -0700 From: Jason Gunthorpe To: linux-rdma@vger.kernel.org Cc: Jason Gunthorpe Subject: [PATCH rdma-core 04/10] verbs: Consolidate duplicate code in create_rwq_ind_table Date: Thu, 22 Nov 2018 16:24:10 -0700 Message-Id: <20181122232416.30132-5-jgg@ziepe.ca> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181122232416.30132-1-jgg@ziepe.ca> References: <20181122232416.30132-1-jgg@ziepe.ca> MIME-Version: 1.0 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: Jason Gunthorpe The usual pattern for an _ex API with a core flex array is to have the core code allocate the variable length command buffer and memcpy the udata into the end of it. Tidy this up to follow the usual pattern. Since no drivers have udata here don't bother passing anything from the driver. Also update the PABI to v22. Signed-off-by: Jason Gunthorpe --- CMakeLists.txt | 3 ++- debian/control | 2 +- debian/libibverbs1.symbols | 2 +- libibverbs/cmd.c | 33 +++++++++++++-------------------- libibverbs/driver.h | 4 ---- providers/mlx4/verbs.c | 25 +++---------------------- providers/mlx5/verbs.c | 24 +++--------------------- 7 files changed, 23 insertions(+), 70 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ca5d49d7301cd2..09cf3a123feb48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,8 +59,9 @@ set(PACKAGE_NAME "RDMA") # See Documentation/versioning.md set(PACKAGE_VERSION "22.0") # When this is changed the values in these files need changing too: +# debian/control # debian/libibverbs1.symbols -set(IBVERBS_PABI_VERSION "21") +set(IBVERBS_PABI_VERSION "22") set(IBVERBS_PROVIDER_SUFFIX "-rdmav${IBVERBS_PABI_VERSION}.so") #------------------------- diff --git a/debian/control b/debian/control index 92888f9aeb2cab..4debe4e961e812 100644 --- a/debian/control +++ b/debian/control @@ -151,7 +151,7 @@ Section: libs Pre-Depends: ${misc:Pre-Depends} Depends: adduser, ${misc:Depends}, ${shlibs:Depends} Recommends: ibverbs-providers -Breaks: ibverbs-providers (<< 21~) +Breaks: ibverbs-providers (<< 22~) Description: Library for direct userspace use of RDMA (InfiniBand/iWARP) libibverbs is a library that allows userspace processes to use RDMA "verbs" as described in the InfiniBand Architecture Specification and diff --git a/debian/libibverbs1.symbols b/debian/libibverbs1.symbols index 643435ad146097..774862e63751ae 100644 --- a/debian/libibverbs1.symbols +++ b/debian/libibverbs1.symbols @@ -3,7 +3,7 @@ libibverbs.so.1 libibverbs1 #MINVER# IBVERBS_1.0@IBVERBS_1.0 1.1.6 IBVERBS_1.1@IBVERBS_1.1 1.1.6 IBVERBS_1.5@IBVERBS_1.5 20 - (symver)IBVERBS_PRIVATE_21 21 + (symver)IBVERBS_PRIVATE_22 22 ibv_ack_async_event@IBVERBS_1.0 1.1.6 ibv_ack_async_event@IBVERBS_1.1 1.1.6 ibv_ack_cq_events@IBVERBS_1.0 1.1.6 diff --git a/libibverbs/cmd.c b/libibverbs/cmd.c index af6ea5cfe12a0f..d485b934a63818 100644 --- a/libibverbs/cmd.c +++ b/libibverbs/cmd.c @@ -2028,38 +2028,31 @@ int ibv_cmd_destroy_wq(struct ibv_wq *wq) int ibv_cmd_create_rwq_ind_table(struct ibv_context *context, struct ibv_rwq_ind_table_init_attr *init_attr, struct ibv_rwq_ind_table *rwq_ind_table, - struct ibv_create_rwq_ind_table *cmd, - size_t cmd_core_size, - size_t cmd_size, struct ib_uverbs_ex_create_rwq_ind_table_resp *resp, - size_t resp_core_size, size_t resp_size) { - int err, i; - uint32_t required_tbl_size, alloc_tbl_size; - uint32_t *tbl_start; - int num_tbl_entries; + struct ibv_create_rwq_ind_table *cmd; + int err; + unsigned int i; + unsigned int num_tbl_entries; + size_t cmd_size; if (init_attr->comp_mask >= IBV_CREATE_IND_TABLE_RESERVED) return EINVAL; - alloc_tbl_size = cmd_core_size - sizeof(*cmd); num_tbl_entries = 1 << init_attr->log_ind_tbl_size; - /* Data must be u64 aligned */ - required_tbl_size = (num_tbl_entries * sizeof(uint32_t)) < sizeof(uint64_t) ? - sizeof(uint64_t) : (num_tbl_entries * sizeof(uint32_t)); - - if (alloc_tbl_size < required_tbl_size) - return EINVAL; + /* The entire message must be size aligned to 8 bytes. */ + cmd_size = sizeof(*cmd) + num_tbl_entries * sizeof(cmd->wq_handles[0]); + cmd_size = (cmd_size + 7) / 8 * 8; + cmd = alloca(cmd_size); - tbl_start = (uint32_t *)((uint8_t *)cmd + sizeof(*cmd)); for (i = 0; i < num_tbl_entries; i++) - tbl_start[i] = init_attr->ind_tbl[i]->handle; + cmd->wq_handles[i] = init_attr->ind_tbl[i]->handle; - IBV_INIT_CMD_RESP_EX_V(cmd, cmd_core_size, cmd_size, + IBV_INIT_CMD_RESP_EX_V(cmd, cmd_size, cmd_size, CREATE_RWQ_IND_TBL, resp, - resp_core_size, resp_size); + sizeof(*resp), resp_size); cmd->log_ind_tbl_size = init_attr->log_ind_tbl_size; cmd->comp_mask = 0; @@ -2069,7 +2062,7 @@ int ibv_cmd_create_rwq_ind_table(struct ibv_context *context, (void) VALGRIND_MAKE_MEM_DEFINED(resp, resp_size); - if (resp->response_length < resp_core_size) + if (resp->response_length < sizeof(*resp)) return EINVAL; rwq_ind_table->ind_tbl_handle = resp->ind_tbl_handle; diff --git a/libibverbs/driver.h b/libibverbs/driver.h index adf46c39e87112..cc879fb61335c7 100644 --- a/libibverbs/driver.h +++ b/libibverbs/driver.h @@ -562,11 +562,7 @@ int ibv_cmd_destroy_wq(struct ibv_wq *wq); int ibv_cmd_create_rwq_ind_table(struct ibv_context *context, struct ibv_rwq_ind_table_init_attr *init_attr, struct ibv_rwq_ind_table *rwq_ind_table, - struct ibv_create_rwq_ind_table *cmd, - size_t cmd_core_size, - size_t cmd_size, struct ib_uverbs_ex_create_rwq_ind_table_resp *resp, - size_t resp_core_size, size_t resp_size); int ibv_cmd_destroy_rwq_ind_table(struct ibv_rwq_ind_table *rwq_ind_table); int ibv_cmd_create_counters(struct ibv_context *context, diff --git a/providers/mlx4/verbs.c b/providers/mlx4/verbs.c index 5b32bd5635ee1f..a88454e405c717 100644 --- a/providers/mlx4/verbs.c +++ b/providers/mlx4/verbs.c @@ -1613,42 +1613,23 @@ int mlx4_destroy_wq(struct ibv_wq *ibwq) struct ibv_rwq_ind_table *mlx4_create_rwq_ind_table(struct ibv_context *context, struct ibv_rwq_ind_table_init_attr *init_attr) { - struct ibv_create_rwq_ind_table *cmd; struct ib_uverbs_ex_create_rwq_ind_table_resp resp = {}; struct ibv_rwq_ind_table *ind_table; - uint32_t required_tbl_size; - unsigned int num_tbl_entries; - int cmd_size; int err; - num_tbl_entries = 1 << init_attr->log_ind_tbl_size; - /* Data must be u64 aligned */ - required_tbl_size = - (num_tbl_entries * sizeof(uint32_t)) < sizeof(uint64_t) ? - sizeof(uint64_t) : (num_tbl_entries * sizeof(uint32_t)); - - cmd_size = required_tbl_size + sizeof(*cmd); - cmd = calloc(1, cmd_size); - if (!cmd) - return NULL; - ind_table = calloc(1, sizeof(*ind_table)); if (!ind_table) - goto free_cmd; + return NULL; - err = ibv_cmd_create_rwq_ind_table(context, init_attr, ind_table, cmd, - cmd_size, cmd_size, &resp, - sizeof(resp), sizeof(resp)); + err = ibv_cmd_create_rwq_ind_table(context, init_attr, ind_table, &resp, + sizeof(resp)); if (err) goto err; - free(cmd); return ind_table; err: free(ind_table); -free_cmd: - free(cmd); return NULL; } diff --git a/providers/mlx5/verbs.c b/providers/mlx5/verbs.c index 46ab8a8935ea70..22a3b9ff23c98c 100644 --- a/providers/mlx5/verbs.c +++ b/providers/mlx5/verbs.c @@ -3258,42 +3258,24 @@ int mlx5_destroy_flow(struct ibv_flow *flow_id) struct ibv_rwq_ind_table *mlx5_create_rwq_ind_table(struct ibv_context *context, struct ibv_rwq_ind_table_init_attr *init_attr) { - struct ibv_create_rwq_ind_table *cmd; struct mlx5_create_rwq_ind_table_resp resp; struct ibv_rwq_ind_table *ind_table; - uint32_t required_tbl_size; - int num_tbl_entries; - int cmd_size; int err; - num_tbl_entries = 1 << init_attr->log_ind_tbl_size; - /* Data must be u64 aligned */ - required_tbl_size = (num_tbl_entries * sizeof(uint32_t)) < sizeof(uint64_t) ? - sizeof(uint64_t) : (num_tbl_entries * sizeof(uint32_t)); - - cmd_size = required_tbl_size + sizeof(*cmd); - cmd = calloc(1, cmd_size); - if (!cmd) - return NULL; - memset(&resp, 0, sizeof(resp)); ind_table = calloc(1, sizeof(*ind_table)); if (!ind_table) - goto free_cmd; + return NULL; - err = ibv_cmd_create_rwq_ind_table(context, init_attr, ind_table, cmd, - cmd_size, cmd_size, &resp.ibv_resp, sizeof(resp.ibv_resp), - sizeof(resp)); + err = ibv_cmd_create_rwq_ind_table(context, init_attr, ind_table, + &resp.ibv_resp, sizeof(resp)); if (err) goto err; - free(cmd); return ind_table; err: free(ind_table); -free_cmd: - free(cmd); return NULL; }