Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2339487imj; Mon, 11 Feb 2019 00:48:26 -0800 (PST) X-Google-Smtp-Source: AHgI3IYkbOhCSj0moaRQNnQJMRqoss+xfHjdbrXw4FqPAim0ySLMRnMvkMAoh1+/HuXUPlCuiDin X-Received: by 2002:a62:109b:: with SMTP id 27mr35144104pfq.227.1549874906088; Mon, 11 Feb 2019 00:48:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549874906; cv=none; d=google.com; s=arc-20160816; b=KxfV5O24VCa7CqnG2WOV0nusrhsOGLt/0Lk0PhS62Ir2+Y8pMMvi8aYg3iZzuojc4i hoaqHL8HdOIEFcW783IccoXdicZuYJX9aOZ9vpVJv22MIx3YciWMzt7wetUuBEs3+FaH P/DojIKZQx4+05xFabVwPhSNjJ1OFruUA0jodffawVSdEVo2Bp0hpg76364Hh0qt8W2H +wFDoftjoTuRyt2zpPhyMzGx+/fF+r8Yj8jFpybK4DENwtaNg8p/VbnbqZse0waBweLx B/bmkJGdrv/+/O7OrL44SkUA7Uv6SA7tZN550KidiQiSw4ZH//faQgo5APHrKdxc+hNL QV1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=ZJGK6UzN/1M5bxWYqDuZXzllyEY8YmoSnFPgEKO1w7U=; b=F+wNYeeGBq4vAFX5MJ09NqczBGnl+klpmyPr2nru031350NlJMr3PtvDLBsdnowzQw ITpxRiL8gWuV2PikNQZzaLniwixae8nnfBsmFXL4vDA/Tj2SViQ3SigJABKx9fv4vE46 OGDoxwwkXiMtJrjpGkygSmcQQ3w4CkmGw84DVPzCekom0aLg8JPS8nj2hF7vHLCdXmfH elw1o0XQN7CTX2YIwlHQXMWeGKtoveIRiDqEfwqHsJNpptRQYqqlwz7bXiXASo9nudK3 3IJezZvbMSzNVFZu4FZln/1pWzU2RmWs9/0aXN//Af6si+F4lkOtXlmTdT38ltupGrTg Y1ZQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m24si8458131pgv.472.2019.02.11.00.48.10; Mon, 11 Feb 2019 00:48:26 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727236AbfBKIqD (ORCPT + 99 others); Mon, 11 Feb 2019 03:46:03 -0500 Received: from mga12.intel.com ([192.55.52.136]:18720 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725931AbfBKIqD (ORCPT ); Mon, 11 Feb 2019 03:46:03 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Feb 2019 00:46:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,358,1544515200"; d="scan'208";a="116930851" Received: from lahna.fi.intel.com (HELO lahna) ([10.237.72.157]) by orsmga008.jf.intel.com with SMTP; 11 Feb 2019 00:45:59 -0800 Received: by lahna (sSMTP sendmail emulation); Mon, 11 Feb 2019 10:45:58 +0200 Date: Mon, 11 Feb 2019 10:45:58 +0200 From: Mika Westerberg To: Lukas Wunner Cc: linux-kernel@vger.kernel.org, Michael Jamet , Yehezkel Bernat , Andreas Noever , Andy Shevchenko Subject: Re: [PATCH v2 14/28] thunderbolt: Extend tunnel creation to more than 2 adjacent switches Message-ID: <20190211084558.GU7875@lahna.fi.intel.com> References: <20190206131738.43696-1-mika.westerberg@linux.intel.com> <20190206131738.43696-15-mika.westerberg@linux.intel.com> <20190210153328.44ur6o5z2xjae42c@wunner.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190210153328.44ur6o5z2xjae42c@wunner.de> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Feb 10, 2019 at 04:33:28PM +0100, Lukas Wunner wrote: > On Wed, Feb 06, 2019 at 04:17:24PM +0300, Mika Westerberg wrote: > > Now that we can allocate hop IDs per port on a path, we can take > > advantage of this and create tunnels covering longer paths than just > > between two adjacent switches. PCIe actually does not need this as it is > > always a daisy chain between two adjacent switches but this way we do > > not need to hard-code creation of the tunnel. > > That doesn't seem to be correct, at the bottom of this page there's > a figure showing a PCI tunnel between non-adjacent switches (blue line): > > https://developer.apple.com/library/archive/documentation/HardwareDrivers/Conceptual/ThunderboltDevGuide/Basics/Basics.html > > I'm not sure if there are advantages to such tunnels: Reduced latency > perhaps because packets need not pass through PCIe adapters on the > in-between device? Or maybe this allows for more fine-grained traffic > prioritization? Interesting. Are you sure Apple actually uses setup like that? I think I have never seen such configuration happening on any of the devices I have. I can update the changelog to mention that if you think it is useful. Something like below maybe? PCIe actually does not need this as it is typically a daisy chain between two adjacent switches but this way we do not need to hard-code creation of the tunnel. > > + i = 0; > > + tb_for_each_port(in_port, src, dst) > > + i++; > > This looks more complicated than necessary. Isn't the path length > always the length of the route string from in_port switch to out_port > switch, plus 2 for the adapter on each end? Or do paths without > adapters exist? Yes, I think you are right. > > + for (i = 0; i < num_hops; i++) { > > + in_port = tb_port_get_next(src, dst, out_port); > > + > > + if (in_port->dual_link_port && in_port->link_nr != link_nr) > > + in_port = in_port->dual_link_port; > > + > > + ret = tb_port_alloc_in_hopid(in_port, in_hopid, -1); > > + if (ret < 0) > > + goto err; > > + in_hopid = ret; > > + > > + out_port = tb_port_get_next(src, dst, in_port); > > + if (!out_port) > > + goto err; > > There's a NULL pointer check here, but the invocation of tb_port_get_next() > further up to assign in_port lacks such a check. Is it guaranteed to never > be NULL? No, I'll add NULL check there.