Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1089010imu; Wed, 9 Jan 2019 11:24:42 -0800 (PST) X-Google-Smtp-Source: ALg8bN6K6opfwn0XeHzwkEPpXbGs69mnoOX2q1cv/djxMpVOpPUB8VkfrYCTvoLszV8zc1Kp7oBy X-Received: by 2002:a62:5b44:: with SMTP id p65mr7119631pfb.47.1547061882395; Wed, 09 Jan 2019 11:24:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547061882; cv=none; d=google.com; s=arc-20160816; b=zZgS76ttgHtAybwDkrvHF+kRJa4rygLM3ygQdQn3olbJElzKZ5GsOFduzN1NRuW+sa YQ1qIz1lzoIVMyfDS/nTVDbGtOjetZsIwPGOOZTbevFRod3i3RpxlVkY02bV01IP4cQ0 MzzLz+qp/l1jUUroecg5BOfyZ1V3kcrWFDpkxVQihk+hdcaidE6IUot1H4ucbNypravH w9usUXQTXGlJbIqO3vRYBtgYM6niROPpWO4MlMjKe0kRTNb9FaQG1jmrvwmt8numI84u EVBOASbtc+6gPUUQ4UBaLZ/W3BZWb4IXQx6or5ZO4Y5EH8IOMg13Z9eHwHm/ZWdnJzfM fgoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:cc:to:from; bh=1atFsQgmHDA5PuP4Fg/NyDudP+NeOBxAYlhHyZravuY=; b=X44Oqkp6ZNkAz7BPK9bZkKRIfN8Er1/URRB7Nx3qFjpg60tmdUvqr5bsMolfcLUBY6 eACBfNfMu2sdK1VeyehX9GnSLSym29O8t8r1G5IBNYeHIcR4KV25BBMfWoAn7sXnrJq0 sMfBBVNjJNjPKurN3h4pZscJ/EsMbN+tj9uUMQQbX4J/VkoOK4PoIm7rtvO0X7hV2/t8 XKqfAbqNTgo5bSXWqV4705P7PannDI9V3gE5gmNiksgWemOSFppQKG4NmwgCWysI2G2U dCeImFAWhKi4VFy9gdLEvI3slwwaLfp6kry/BomWQTE6fb+oLbmAh5u/1ofy8KVj1ZMO SWPQ== 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 k125si29571011pfc.21.2019.01.09.11.24.27; Wed, 09 Jan 2019 11:24:42 -0800 (PST) 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 S1728290AbfAITW5 (ORCPT + 99 others); Wed, 9 Jan 2019 14:22:57 -0500 Received: from ale.deltatee.com ([207.54.116.67]:59758 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728463AbfAITWv (ORCPT ); Wed, 9 Jan 2019 14:22:51 -0500 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 1ghJR2-00053u-GL; Wed, 09 Jan 2019 12:22:50 -0700 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.89) (envelope-from ) id 1ghJR1-0001Vt-L2; Wed, 09 Jan 2019 12:22:39 -0700 From: Logan Gunthorpe To: linux-kernel@vger.kernel.org, linux-ntb@googlegroups.com, Jon Mason Cc: Allen Hubbe , Dave Jiang , Serge Semin , Logan Gunthorpe Date: Wed, 9 Jan 2019 12:22:31 -0700 Message-Id: <20190109192233.5752-7-logang@deltatee.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20190109192233.5752-1-logang@deltatee.com> References: <20190109192233.5752-1-logang@deltatee.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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, logang@deltatee.com X-SA-Exim-Mail-From: gunthorp@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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.2 Subject: [PATCH v3 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 Acked-by: Allen Hubbe Tested-by: Alexander Fomichev --- 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 bd0474e62a40..7165f7ab8e35 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.19.0