Received: by 10.223.164.202 with SMTP id h10csp264939wrb; Thu, 30 Nov 2017 09:58:49 -0800 (PST) X-Google-Smtp-Source: AGs4zMbuvhrp4FJ0G0VoX5nYkiqNaYoF85NIjI76NTZMDxltSC1hEcj1ssE/oMRid9jgKbz+GpJ9 X-Received: by 10.84.135.101 with SMTP id 92mr3558375pli.172.1512064729137; Thu, 30 Nov 2017 09:58:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512064729; cv=none; d=google.com; s=arc-20160816; b=LKzPbcwGRxsKrmP5WNl8WRgVVW/QL8kHPNLKkLPlBtDPk5Z1natjR9ndwMJKVvd/H0 DEdA0JRw3IJX+BIQ/eG4kNs/CGJMziuCyCsV19LEUWGJxjYAfdpFOJH1zE+mxbDI+lgW LYNplgTHLAYvlddwWhiyJED4DtlVqWcZf7es+DaWea5ufVaGr53lOn9RBQ01KPd8u6AD HPxjcFgymp9ALRffNkIXikpFGoz24uh3XjPbrVUPKZ/K3xA/Ug+CC/t5iGbq2VH8ZKWQ sBHg+2SG/YjwAJaokElG4IYBA/INm0XVw4EfzPaqxR77fCNTjnJvzJO7QxN8+X1fVpRO IUbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=8+HuitJtr3dBry0cDNFG1B2+hYIFG0yDa6dbo0Pffko=; b=0RofLbfzVsDCEJX6iR/TIuBi35vo2DZLI1eDmpxtP31CN4mbV3GAAw+2+vzdYEsUeH 0Jzzh9B+N7dtiHKTQRwJTBPkMqnZykcRYbT3SeT838XCoAsXN/GfoYKNvg+ohSNnxoMo ZPEjHBPOmpdLcaUoL0xHJicBJiJiZP+npSLgphPjo8d3oVO6FFHDc2C+pIuBZkmko1VN QutwCAj5MTcORiNg5mG7Tk3G6uTMEQqBs7eEmh7b3sayETZfRjr+Fe7XGx9WNO9RM+Xq jgjFHC5buTDl0w4P3xRJtYQ8XTv6E84R8wN2Iz+tdQawjGpSFzVARtFXOpgvnYvnawrE CbEA== 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 n189si3615021pfn.40.2017.11.30.09.58.35; Thu, 30 Nov 2017 09:58:49 -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 S1753945AbdK3R4z (ORCPT + 99 others); Thu, 30 Nov 2017 12:56:55 -0500 Received: from mail.savoirfairelinux.com ([208.88.110.44]:58236 "EHLO mail.savoirfairelinux.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753850AbdK3R4x (ORCPT ); Thu, 30 Nov 2017 12:56:53 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 144849C31B6; Thu, 30 Nov 2017 12:56:53 -0500 (EST) Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id sg_AnD13fST3; Thu, 30 Nov 2017 12:56:52 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 8EF619C31B4; Thu, 30 Nov 2017 12:56:52 -0500 (EST) X-Virus-Scanned: amavisd-new at mail.savoirfairelinux.com Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id w0a2SXBWqazW; Thu, 30 Nov 2017 12:56:52 -0500 (EST) Received: from weeman.mtl.sfl (unknown [192.168.49.104]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id 646009C3177; Thu, 30 Nov 2017 12:56:52 -0500 (EST) From: Vivien Didelot To: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel@savoirfairelinux.com, "David S. Miller" , Florian Fainelli , Andrew Lunn , Vivien Didelot Subject: [PATCH net-next 1/2] net: dsa: introduce dsa_towards_port helper Date: Thu, 30 Nov 2017 12:56:42 -0500 Message-Id: <20171130175643.14022-2-vivien.didelot@savoirfairelinux.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171130175643.14022-1-vivien.didelot@savoirfairelinux.com> References: <20171130175643.14022-1-vivien.didelot@savoirfairelinux.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a new helper returning the local port used to reach an arbitrary switch port in the fabric. Its only user at the moment is the dsa_upstream_port helper, which returns the local port reaching the dedicated CPU port, but it will be used in cross-chip FDB operations. Signed-off-by: Vivien Didelot --- include/net/dsa.h | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/include/net/dsa.h b/include/net/dsa.h index 2a05738570d8..f90f342dc5b4 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -296,20 +296,23 @@ static inline u32 dsa_user_ports(struct dsa_switch *ds) return mask; } +/* Return the local port used to reach an arbitrary switch port */ +static inline unsigned int dsa_towards_port(struct dsa_switch *ds, int device, + int port) +{ + if (device == ds->index) + return port; + else + return ds->rtable[device]; +} + +/* Return the local port used to reach the dedicated CPU port */ static inline u8 dsa_upstream_port(struct dsa_switch *ds) { struct dsa_switch_tree *dst = ds->dst; + struct dsa_port *cpu_dp = dst->cpu_dp; - /* - * If this is the root switch (i.e. the switch that connects - * to the CPU), return the cpu port number on this switch. - * Else return the (DSA) port number that connects to the - * switch that is one hop closer to the cpu. - */ - if (dst->cpu_dp->ds == ds) - return dst->cpu_dp->index; - else - return ds->rtable[dst->cpu_dp->ds->index]; + return dsa_towards_port(ds, cpu_dp->ds->index, cpu_dp->index); } typedef int dsa_fdb_dump_cb_t(const unsigned char *addr, u16 vid, -- 2.15.0 From 1585518447759140177@xxx Thu Nov 30 18:57:01 +0000 2017 X-GM-THRID: 1585517940150114735 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread