Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3152718imm; Fri, 20 Jul 2018 11:02:40 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeb9zxocnce6v5vhwEzmF+MUB5Ukw2P9oOpBQupv/xsS/06BI5umzICidDDTlKGGArDosjX X-Received: by 2002:a62:ad1:: with SMTP id 78-v6mr3167070pfk.57.1532109760868; Fri, 20 Jul 2018 11:02:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532109760; cv=none; d=google.com; s=arc-20160816; b=swz23Vdr6kBte+7v/xtvgjR0wg0bNq76WglQAjOn9afQl3OkDWMvAv0b9PyahhjpuR suQEyQBPGMHBSzWCsyjbCoxAyZNWBmO4sPa13deFOfLLx0cGTKuYqhewW3gvrgI+a/qn Y4GPlmypRvmiaDxyFF1iZ84MOd4l96uQLuBb0L9G/uO9hqinurm8R0NW4mYGW1ts+Ugd fcSqM+5vy+pioGLvE/XeGU3BykZfy/zq4yEwhGkuNkCXLtetGr4bEEmDmaxQxalfW9dZ HrqSToLAb54H1Af3yVAMo6wReHUaPx1ycDKfYM627+U/m8L9P1I7buhZTzTUWuJSiCMW cXAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:references:in-reply-to:message-id :date:cc:to:from:arc-authentication-results; bh=54sp09xaimnl39TQ17+9xsnom4bBcVxDoAnT0H5ROmA=; b=Q8W7cj+FJLANudRe7tk9NAsAufqPdOTN86kAnUTIN3olj/HMDREidfUxFK21t0WRMI Uo2KxBJKbJZfQIN1UEDoucZO+rGIy92HApj6cijNA3UiKNydEUcd3Aao0bjATTCJJJ/U W9LakNfxqMZdh/1RCIcJ6BbU4oZW76IwyFx/03e0Ky2loqhoyAWhLkuJddfhtvyNOYZS t/dbM7jZF3U2qXIlUD3/UyzIoq7FIkZ002d1wF5BN5ScMigsrVNe5sNMPFHG+sRQj432 DBmRFKX410F3fy8PVqhd5hD65RXHtnj1K7yQw63aldCTtpg7XPDh/gQkwYy7Q7S3jFG/ m4jA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d2-v6si2297313pln.471.2018.07.20.11.02.23; Fri, 20 Jul 2018 11:02:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388307AbeGTSuE (ORCPT + 99 others); Fri, 20 Jul 2018 14:50:04 -0400 Received: from ale.deltatee.com ([207.54.116.67]:38348 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387950AbeGTSuE (ORCPT ); Fri, 20 Jul 2018 14:50:04 -0400 Received: from cgy1-donard.priv.deltatee.com ([172.16.1.31]) by ale.deltatee.com with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1fgZhn-0008E6-0U; Fri, 20 Jul 2018 12:00:41 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.89) (envelope-from ) id 1fgZhl-000132-9F; Fri, 20 Jul 2018 12:00:37 -0600 From: Logan Gunthorpe To: linux-kernel@vger.kernel.org, linux-ntb@googlegroups.com, Jon Mason Cc: Allen Hubbe , Serge Semin , Shyam Sundar S K , Shuah Khan , Doug Meyer , Logan Gunthorpe Date: Fri, 20 Jul 2018 12:00:32 -0600 Message-Id: <20180720180034.3964-7-logang@deltatee.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180720180034.3964-1-logang@deltatee.com> References: <20180720180034.3964-1-logang@deltatee.com> X-SA-Exim-Connect-IP: 172.16.1.31 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-ntb@googlegroups.com, jdmason@kudzu.us, allenbh@gmail.com, fancer.lancer@gmail.com, Shyam-sundar.S-k@amd.com, shuah@kernel.org, dmeyer@gigaio.com, logang@deltatee.com X-SA-Exim-Mail-From: gunthorp@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-8.7 required=5.0 tests=ALL_TRUSTED,BAYES_00, GREYLIST_ISWHITE,MYRULES_NO_TEXT autolearn=ham autolearn_force=no version=3.4.1 Subject: [PATCH v2 6/8] NTB: perf: Fix support for hardware that doesn't have port numbers X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Legacy drivers do not have port numbers (but is reliably only two ports) and was broken by the recent commit that added mult-port support to ntb_perf. This is especially important to support the cross link topology which is perfectly symmetric and cannot assign unique port numbers easily. Hardware that returns zero for both the local port and the peer should just always use gidx=0 for the only peer. Fixes: 5648e56d03fa ("NTB: ntb_perf: Add full multi-port NTB API support") Signed-off-by: Logan Gunthorpe --- drivers/ntb/test/ntb_perf.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/ntb/test/ntb_perf.c b/drivers/ntb/test/ntb_perf.c index fe27412ffe91..6285cb8515ac 100644 --- a/drivers/ntb/test/ntb_perf.c +++ b/drivers/ntb/test/ntb_perf.c @@ -1417,6 +1417,16 @@ static int perf_init_peers(struct perf_ctx *perf) if (perf->gidx == -1) perf->gidx = pidx; + /* + * Hardware with only two ports may not have unique port + * numbers. In this case, the gidxs should all be zero. + */ + if (perf->pcnt == 1 && ntb_port_number(perf->ntb) == 0 && + ntb_peer_port_number(perf->ntb, 0) == 0) { + perf->gidx = 0; + perf->peers[0].gidx = 0; + } + for (pidx = 0; pidx < perf->pcnt; pidx++) { ret = perf_setup_peer_mw(&perf->peers[pidx]); if (ret) -- 2.11.0