From patchwork Wed Jun 14 14:00:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13280101 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ADB00EB64D8 for ; Wed, 14 Jun 2023 14:01:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236308AbjFNOBL (ORCPT ); Wed, 14 Jun 2023 10:01:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245324AbjFNOBD (ORCPT ); Wed, 14 Jun 2023 10:01:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AAB51BC6 for ; Wed, 14 Jun 2023 07:01:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D3E5F63F79 for ; Wed, 14 Jun 2023 14:01:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DEF8CC433C8; Wed, 14 Jun 2023 14:01:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686751261; bh=BQsvPIcbmiqCskEL61I0tER2ROKUt45q7hKBes3HzJo=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=ej3NjMo0VHMaeDmfPXyWkl32vCr6gN1QI8wZrgEu5BaFPtzQoBmMhNTa5N1De9fYU crzrbtPbuXKLos+P5IsS6A4dZ+jQ+tjM+/tOuag74WHdR+OoafBbwjPCszwQwTLqC3 hq/PKlKxP9I58pcTjzPVMdZ3Lsjp5O81hSJARDIokgLDXU+zSxfeV7fL/RB7/jCnZn YIHGzvWvUWMtP/2uSG7wj5lfNjJnVKHB7qLFWs0Y/7Z+2eU9vQQ+I6kGlvA9JcgxpT o5DIqBg+9mF6iTZwGqI56q2I+P89hnnnloEnp02evSEtJjVGPsrDf7mno2uIVW1uAP OW0VSYz8zJGrw== Subject: [PATCH v3 4/4] RDMA/cma: Avoid GID lookups on iWARP devices From: Chuck Lever To: jgg@nvidia.com Cc: Chuck Lever , linux-rdma@vger.kernel.org, tom@talpey.com, BMT@zurich.ibm.com Date: Wed, 14 Jun 2023 10:00:59 -0400 Message-ID: <168675125998.2279.7297073638926155456.stgit@manet.1015granger.net> In-Reply-To: <168675101993.2279.4985978457935843722.stgit@manet.1015granger.net> References: <168675101993.2279.4985978457935843722.stgit@manet.1015granger.net> User-Agent: StGit/1.5 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Chuck Lever We would like to enable the use of siw on top of a VPN that is constructed and managed via a tun device. That hasn't worked up until now because ARPHRD_NONE devices (such as tun devices) have no GID for the RDMA/core to look up. But it turns out that the egress device has already been picked for us -- no GID is necessary. addr_handler() just has to do the right thing with it. Suggested-by: Jason Gunthorpe Signed-off-by: Chuck Lever --- drivers/infiniband/core/cma.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index a1756ed1faa1..50b8da2c4720 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -700,6 +700,19 @@ cma_validate_port(struct ib_device *device, u32 port, if ((dev_type != ARPHRD_INFINIBAND) && rdma_protocol_ib(device, port)) goto out; + if (rdma_protocol_iwarp(device, port)) { + sgid_attr = rdma_get_gid_attr(device, port, 0); + if (IS_ERR(sgid_attr)) + goto out; + + /* XXX: I don't think this is RCU-safe, but does it need to be? */ + ndev = rcu_dereference(sgid_attr->ndev); + if (!net_eq(dev_net(ndev), dev_addr->net) || + ndev->ifindex != bound_if_index) + sgid_attr = ERR_PTR(-ENODEV); + goto out; + } + if (dev_type == ARPHRD_ETHER && rdma_protocol_roce(device, port)) { ndev = dev_get_by_index(dev_addr->net, bound_if_index); if (!ndev)