Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1460529imm; Fri, 8 Jun 2018 17:11:35 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIqUIkeifsrfOK4Hw4BOkkzJ/C71JWIjDNr8wnAn5k2Bm/jLrCRN4yvp96WTIuSEqWjyj8T X-Received: by 2002:a65:444f:: with SMTP id e15-v6mr7080687pgq.348.1528503095115; Fri, 08 Jun 2018 17:11:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528503095; cv=none; d=google.com; s=arc-20160816; b=caiqWyFJI6YT2vRoYbQ8pWbmCNPsEsgf3HZ5J37e6kcNNJbiDfNgUOlVE8BCjC9+JG HLLUa20HPTvGNYChthSkQrg0LVYTo+tm2fD0MI6ikjcjAZbUgEvxNHSjt4ucLyrpNw2d uFhZ05hc0ye+fV5kF2KP+EF93Ffq+lAoM6rbsAPB4qabnseLjRualF71vrVe3V/oeMjy MJfTFa/kgENu2Iayu2NhLNABrPVU5pYmSFqP+gnn94ZAfApkW/kqXfRLQC2+CMImj8XE dq1PKm7hutsX00iEjUdqYR5tUkmcL6tHEpT+8FdmAUI59GKetu4rAW7NdqWbUBXz3mhE 4uvQ== 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=M0ljWtPVaBdRqX1xEk3W2YUtV2UEd992TO/nijb5PM8348PnqOa9kMzDdEOxsHXgx4 qPorWjaIoHZB3iz11oLR45qVaNYlHObxY1LSkLsXCFv+NUOktPDkAnq/1xTG8N+r8M0A Gs/lanvTdEOliDO5FMmbL3i42GQI0mJ17TujWAZY0Qkynq8b7CQAe0b0E69u92bpNnCM LlHq/BC6ZJc6M9a3ZU0i6ZoQ+5CaqpGp64rsijRVLAXBW39coLnq/yqJntHaWRocEhAY eZhw2Nb9x2kgvZlsdbQZfy+oJ3smVdgoQe4ZwzEAtdh2LUR8yrmmrBlGTsy657Xkm7Br bvSg== 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 x2-v6si55235551plv.388.2018.06.08.17.11.20; Fri, 08 Jun 2018 17:11:35 -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 S932236AbeFIAJa (ORCPT + 99 others); Fri, 8 Jun 2018 20:09:30 -0400 Received: from ale.deltatee.com ([207.54.116.67]:60586 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753100AbeFIAI1 (ORCPT ); Fri, 8 Jun 2018 20:08:27 -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 1fRRQd-00043t-2R; Fri, 08 Jun 2018 18:08:27 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.89) (envelope-from ) id 1fRRQc-0003d5-6l; Fri, 08 Jun 2018 18:08:22 -0600 From: Logan Gunthorpe To: linux-kernel@vger.kernel.org, linux-ntb@googlegroups.com Cc: Jon Mason , Dave Jiang , Allen Hubbe , Serge Semin , Shyam Sundar S K , Shuah Khan , Logan Gunthorpe Date: Fri, 8 Jun 2018 18:08:17 -0600 Message-Id: <20180609000819.13883-8-logang@deltatee.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180609000819.13883-1-logang@deltatee.com> References: <20180609000819.13883-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, dave.jiang@intel.com, allenbh@gmail.com, fancer.lancer@gmail.com, Shyam-sundar.S-k@amd.com, shuah@kernel.org, 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 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