Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1089757imu; Wed, 9 Jan 2019 11:25:34 -0800 (PST) X-Google-Smtp-Source: ALg8bN6wEleAALm++IOHNhPx5+gZfoijft8yHo6l4Wqr8kCg45L303puR/DD5o3vq3wkVcgyUwSo X-Received: by 2002:a17:902:7791:: with SMTP id o17mr7210149pll.60.1547061934488; Wed, 09 Jan 2019 11:25:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547061934; cv=none; d=google.com; s=arc-20160816; b=CG6H605m/GreSDdtOB3RjUx0OMEF31Uya7S8HBrHDe+Phe2qmP5k1jXGvIaKUVj6XJ 9yquBNP+ImkJrZOKYY/6PC+QoM46wrw1h8Mbxlvp9hhUAgfqd3I5agP8esxycFpeipb5 MGsHJg8IWhGvrB3ltREi2T3JI6t9PzVzfKB/0Ige0JFZMblhN1ru16bpqtF4pNI7FAHN fyOQkRqvGH8lonN2kTYMhvMyaPWe5VaYkr+/xzZbWN2ir95wtSZRKiVIWQzZ8jsJHyAs 4jgLzPghZpuZ4yPQXw9RLci71Y++gqOsOkPqxoiTkM+IGBw/S9onrO8TDdCQQXBJg5CY 2jGg== 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=2xuDpuAzYD2wLC/BXXNRH/r0RKAtPd863ozbK/0ssZg=; b=Gj3TG3G20JPRKUqo/sNm7uJvdBEqWJGcJl5y41vr+4bs5NS3szgdOme3x4FB3M5lDy +jT1t6UWPjoy/tNBBPPxDouQVm75/BtTyd0ly1DyF/DqgV7Pwikh71xzepwjedMyfD/C UcerE23P3kVqMGwLF/MOAEsbNWGJhApM00YJ5TD1rF5iss04SDckoh6t8tQ3Ym84rMdG JQdgoFLC0gv8otCcZn8+qUZhno4haEr7eA4QWkEsuOjxfAciXdar4sXlRMbBjdVSOk2x aFfoDDCn7Bt8Rmn3C2QBo5vBgwAU3F3IXO/MWHdXrwXf5t6rGEa+dXcq8UEkXn/95wGq eSpA== 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 z5si21061959pgj.177.2019.01.09.11.25.18; Wed, 09 Jan 2019 11:25:34 -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 S1728566AbfAITXX (ORCPT + 99 others); Wed, 9 Jan 2019 14:23:23 -0500 Received: from ale.deltatee.com ([207.54.116.67]:59698 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728449AbfAITWs (ORCPT ); Wed, 9 Jan 2019 14:22:48 -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-00053s-GD; Wed, 09 Jan 2019 12:22:46 -0700 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.89) (envelope-from ) id 1ghJR1-0001Vn-F6; 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:29 -0700 Message-Id: <20190109192233.5752-5-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 4/8] NTB: ntb_pingpong: Choose doorbells based on port number 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 This commit fixes pingpong support for existing drivers that do not implement ntb_default_port_number() and ntb_default_peer_port_number(). This is required for hardware (like the crosslink topology of switchtec) which cannot assign reasonable port numbers to each port due to its perfect symmetry. Instead of picking the doorbell to use based on the the index of the peer, we use the peer's port number. This is a bit clearer and easier to understand. Fixes: c7aeb0afdcc2 ("NTB: ntb_pp: Add full multi-port NTB API support") Signed-off-by: Logan Gunthorpe Acked-by: Allen Hubbe Tested-by: Alexander Fomichev --- drivers/ntb/test/ntb_pingpong.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/ntb/test/ntb_pingpong.c b/drivers/ntb/test/ntb_pingpong.c index 65865e460ab8..18d00eec7b02 100644 --- a/drivers/ntb/test/ntb_pingpong.c +++ b/drivers/ntb/test/ntb_pingpong.c @@ -121,15 +121,14 @@ static int pp_find_next_peer(struct pp_ctx *pp) link = ntb_link_is_up(pp->ntb, NULL, NULL); /* Find next available peer */ - if (link & pp->nmask) { + if (link & pp->nmask) pidx = __ffs64(link & pp->nmask); - out_db = BIT_ULL(pidx + 1); - } else if (link & pp->pmask) { + else if (link & pp->pmask) pidx = __ffs64(link & pp->pmask); - out_db = BIT_ULL(pidx); - } else { + else return -ENODEV; - } + + out_db = BIT_ULL(ntb_peer_port_number(pp->ntb, pidx)); spin_lock(&pp->lock); pp->out_pidx = pidx; @@ -303,7 +302,7 @@ static void pp_init_flds(struct pp_ctx *pp) break; } - pp->in_db = BIT_ULL(pidx); + pp->in_db = BIT_ULL(lport); pp->pmask = GENMASK_ULL(pidx, 0) >> 1; pp->nmask = GENMASK_ULL(pcnt - 1, pidx); @@ -435,4 +434,3 @@ static void __exit pp_exit(void) debugfs_remove_recursive(pp_dbgfs_topdir); } module_exit(pp_exit); - -- 2.19.0