From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2CD2EC433DF for ; Wed, 22 Jul 2020 12:14:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 073A920771 for ; Wed, 22 Jul 2020 12:14:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="c1IugX0P" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726462AbgGVMOI (ORCPT ); Wed, 22 Jul 2020 08:14:08 -0400 Received: from smtp-fw-9102.amazon.com ([207.171.184.29]:62713 "EHLO smtp-fw-9102.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726161AbgGVMOI (ORCPT ); Wed, 22 Jul 2020 08:14:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1595420047; x=1626956047; h=subject:to:cc:references:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=X3s+lSlfGlNpFYrUI80Hl7OIdvSTeIvd+Aix5hakY3Q=; b=c1IugX0PIENlNOys68Iy6FtAvK0mKvzM78SFlWdHzKbTdwuIh/J3R+4B Usiiz/Inb0bbEQf3dJdk0U2MVHDX/KP5tYPJtJaZWFhwsGfpvlko9fwKU JWiLu4gsT+oy1ujSCaVL4DKM8Ls/7uQ/KiXvQlsKkS7B11K5g+kN6sSVR M=; IronPort-SDR: qjJrjomknniPt9xyMoY1riN/l+mkymu5l6Lpl8FDdsnyYasoMzrWTEjmLUH6DbFd3SMKglU0I/ Q3u4gVkFyMOQ== X-IronPort-AV: E=Sophos;i="5.75,381,1589241600"; d="scan'208";a="61914042" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-2b-5bdc5131.us-west-2.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP; 22 Jul 2020 12:14:06 +0000 Received: from EX13MTAUEA002.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan3.pdx.amazon.com [10.170.41.166]) by email-inbound-relay-2b-5bdc5131.us-west-2.amazon.com (Postfix) with ESMTPS id 79836A2BFC; Wed, 22 Jul 2020 12:14:06 +0000 (UTC) Received: from EX13D19EUB003.ant.amazon.com (10.43.166.69) by EX13MTAUEA002.ant.amazon.com (10.43.61.77) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 22 Jul 2020 12:14:05 +0000 Received: from 8c85908914bf.ant.amazon.com (10.43.160.65) by EX13D19EUB003.ant.amazon.com (10.43.166.69) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 22 Jul 2020 12:14:02 +0000 Subject: Re: [PATCH for-next v3 3/4] RDMA/efa: User/kernel compatibility handshake mechanism To: Jason Gunthorpe CC: Doug Ledford , , Alexander Matushevsky , Shadi Ammouri , Yossi Leybovich References: <20200721133049.74349-1-galpress@amazon.com> <20200721133049.74349-4-galpress@amazon.com> <20200722115548.GH25301@ziepe.ca> <15fcfced-0f4b-563e-7d7f-d448c66201c1@amazon.com> <20200722120819.GI25301@ziepe.ca> From: Gal Pressman Message-ID: <790570eb-dfcf-9763-fada-9faca569da7a@amazon.com> Date: Wed, 22 Jul 2020 15:13:57 +0300 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200722120819.GI25301@ziepe.ca> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.43.160.65] X-ClientProxiedBy: EX13D07UWA003.ant.amazon.com (10.43.160.35) To EX13D19EUB003.ant.amazon.com (10.43.166.69) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org On 22/07/2020 15:08, Jason Gunthorpe wrote: > On Wed, Jul 22, 2020 at 03:04:20PM +0300, Gal Pressman wrote: >> On 22/07/2020 14:55, Jason Gunthorpe wrote: >>> On Tue, Jul 21, 2020 at 04:30:48PM +0300, Gal Pressman wrote: >>>> Introduce a mechanism that performs an handshake between the userspace >>>> provider and kernel driver which verifies that the user supports all >>>> required features in order to operate correctly. >>>> >>>> The handshake verifies the needed functionality by comparing the >>>> reported device caps and the provider caps. If the device reports a >>>> non-zero capability the appropriate comp mask is required from the >>>> userspace provider in order to allocate the context. >>>> >>>> Reviewed-by: Shadi Ammouri >>>> Reviewed-by: Yossi Leybovich >>>> Signed-off-by: Gal Pressman >>>> drivers/infiniband/hw/efa/efa_verbs.c | 49 +++++++++++++++++++++++++++ >>>> include/uapi/rdma/efa-abi.h | 10 ++++++ >>>> 2 files changed, 59 insertions(+) >>>> >>>> diff --git a/drivers/infiniband/hw/efa/efa_verbs.c b/drivers/infiniband/hw/efa/efa_verbs.c >>>> index 26102ab333b2..7ca40df81ee5 100644 >>>> +++ b/drivers/infiniband/hw/efa/efa_verbs.c >>>> @@ -1501,11 +1501,48 @@ static int efa_dealloc_uar(struct efa_dev *dev, u16 uarn) >>>> return efa_com_dealloc_uar(&dev->edev, ¶ms); >>>> } >>>> >>>> +#define EFA_CHECK_COMP(_dev, _comp_mask, _attr, _mask) \ >>>> + (!(_dev)->dev_attr._attr || ((_comp_mask) & (_mask))) >>>> + >>>> +#define DEFINE_COMP_HANDSHAKE(_dev, _comp_mask, _attr, _mask) \ >>>> + { \ >>>> + .attr = #_attr, \ >>>> + .check_comp = EFA_CHECK_COMP(_dev, _comp_mask, _attr, _mask) \ >>>> + } >>>> + >>>> +int efa_user_comp_handshake(const struct ib_ucontext *ibucontext, >>>> + const struct efa_ibv_alloc_ucontext_cmd *cmd) >>>> +{ >>>> + struct efa_dev *dev = to_edev(ibucontext->device); >>>> + int i; >>>> + struct { >>>> + char *attr; >>>> + bool check_comp; >>>> + } user_comp_handshakes[] = { >>>> + DEFINE_COMP_HANDSHAKE(dev, cmd->comp_mask, max_tx_batch, >>>> + EFA_ALLOC_UCONTEXT_CMD_COMP_TX_BATCH), >>>> + DEFINE_COMP_HANDSHAKE(dev, cmd->comp_mask, min_sq_depth, >>>> + EFA_ALLOC_UCONTEXT_CMD_COMP_MIN_SQ_WR), >>>> + }; >>> >>> This seems like a very expensive construct >>> >>> Why have the array at all? Just list the macros and have them jump to >>> err >> >> Do you mean: >> >> if (CHECK_COMP(x1)) { >> ibdev_dbg(err); >> goto err; >> } >> >> if (CHECK_COMP(x2)) { >> ibdev_dbg(err); >> goto err; >> } >> >> [...] >> >> That adds much more boilerplate code for each feature. Or do you have something >> else in mind? > > #define DO_COMP_HANDSHAKE() \ > if (...) goto err > > DO_COMP_HANDSHAKE(x1) > DO_COMP_HANDSHAKE(2) I'd rather not have gotos inside macros, I find that very confusing. I can add the ifs I suggested if you want the array removed.