Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4748663ybg; Mon, 21 Oct 2019 13:54:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqxggR+gLqFQ1TQbFoPCOxnEroVHOnP+MYt5ESy845kbCU3W0Uz9M0Oo7mL7kHGCfZxDcIJr X-Received: by 2002:a50:cbcd:: with SMTP id l13mr27124408edi.18.1571691296393; Mon, 21 Oct 2019 13:54:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571691296; cv=none; d=google.com; s=arc-20160816; b=DA/Rpn2/D6EUC6VQtRo+nL+SmMm863mcIXneN0MuLYtFM3gUJtwG5MQyUziI3lnR2p xELYWUs7tsvq4WjMvKwAwvoJ7YTPN8ejcbWzD8FUpXSPnfwGVWLQWWOQjTCOBnGm7hJx oDgdISe1B809Y7M9crr8RgISi44Ag+T0uoBnX73SL13G5+f58ZS+GCo9cyLqQm7LcXbA 7JegPwCHdrsKiRR79Yz71nRgbQMaEd6kUCBLwP1w70dNjaOkeKovcHAoEvIHhZ5DG8l5 m5WWqhbyAKGUIz/oJZr4X2wSNRIkZjPt6ozVZ6jH42cveTVilN0rkBTQ9nQj0GVaVupi 9C6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=OoBa2UuF6l2BUY5eIYmAWMJW5SOqVBTZrftuRAjOzXg=; b=ZvKDWrXSgV/a2BpC4xZyMUfyWO52GrOgPaNRInv4CgMOrwCO49JRebINlP8/FnKOJX qo9jBJ7JXyyqIt9ECL4lS2RwHtAT8v9ni1p5H3RwxVkkrevNfcXMYwNJt59x4wlNzFt7 54onASRfQCwMZ5G1C8j4CbVxvDn3qvVSEQ/Ja/NamUFORd1+6ThN9XEaQq40CLN5zqHt G6l/O220BxjRZyX2bJPdObcUWYcPde/4GXjwS91yWzyjAkjAZkoO7BqCeJBr+3GZvKx3 hmMdUFN3lVMg5YJhS0COjL54coQvgoHy+3kr6/HYzXrpv3C5KFrmJ0TqHKmgaelay3FX YwFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="O7X+H/aZ"; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l9si8840750ejq.164.2019.10.21.13.54.33; Mon, 21 Oct 2019 13:54:56 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b="O7X+H/aZ"; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730610AbfJUUwW (ORCPT + 99 others); Mon, 21 Oct 2019 16:52:22 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:43973 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730512AbfJUUv5 (ORCPT ); Mon, 21 Oct 2019 16:51:57 -0400 Received: by mail-qt1-f196.google.com with SMTP id t20so23303748qtr.10; Mon, 21 Oct 2019 13:51:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OoBa2UuF6l2BUY5eIYmAWMJW5SOqVBTZrftuRAjOzXg=; b=O7X+H/aZzciqsx8EG54Z0p6tYDqNZ2zoM+OiWgiiC6qUyt/8gf/IV4ZbEGKUT2nHJ5 igMOMgs/pSheaukxYRum/rH1yjjNWP5yst9ChhHs/VivfhThce0gKObEf0Ou5N+fjbVp d1R0h/4V50WmrjanO8D6bYdSueqK5JaDC/RN3M9xhQclWE3SJTXrZYpi4FvLfISuX/A1 b3QPSdUXr8Lc+dCI2FrxfGGpA3ONEHQtO0WqiYI22cqr50pUieFq59ITz3sFSuMhZrem mIOn/I1/3mubDsL6D7ZJL52mR4CWkfFyrQawdyb6d3leXZrn8BiwGRHljY4nRNoxM8LU VWUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OoBa2UuF6l2BUY5eIYmAWMJW5SOqVBTZrftuRAjOzXg=; b=P3lkHjpQ643V/SpF5nzxzkZ0Rj1tgpV9BJHTFQkZ7iFrOo/sEwhwRY4x5e2P+kU021 lnhfoIrEJfZzLfvcrq/8IjqFG3aIdYl1P8umDz7zlJBuApnlr7EFMwK+WFOlywTMuJV5 a67o4bbRpMlu+wVebKIc6g34o9aYqCphjtP3RcUg5lhvLX3qYFRcgIF7qWKj/Qly0koZ bCVitJvlATxW2ZLmNwxEBwNQDp59fEDwmZthI6btV6eT8ivn9XwkXTg/mhuOzPYJmBN8 e5TgWfJu+ftBdPyGwOgg5PPYGVNfEEPYyu8aoxfaBzV20vbsPGqXVXeJB4L6gfXWWzh/ 7cJw== X-Gm-Message-State: APjAAAUsoYwrKLcZn3tBTlVX+uM9V9j7sN4wcBOshOodPPlI85uEcuB8 uG1Xdv/H8RitD9KbplaZT14= X-Received: by 2002:aed:29c7:: with SMTP id o65mr3484303qtd.266.1571691116267; Mon, 21 Oct 2019 13:51:56 -0700 (PDT) Received: from localhost (modemcable249.105-163-184.mc.videotron.ca. [184.163.105.249]) by smtp.gmail.com with ESMTPSA id t65sm8172592qkh.23.2019.10.21.13.51.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 13:51:55 -0700 (PDT) From: Vivien Didelot To: "David S. Miller" Cc: linux-kernel@vger.kernel.org, Vivien Didelot , Florian Fainelli , Andrew Lunn , netdev@vger.kernel.org Subject: [PATCH net-next v2 13/16] net: dsa: mv88e6xxx: use ports list to map bridge Date: Mon, 21 Oct 2019 16:51:27 -0400 Message-Id: <20191021205130.304149-14-vivien.didelot@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191021205130.304149-1-vivien.didelot@gmail.com> References: <20191021205130.304149-1-vivien.didelot@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of digging into the other dsa_switch structures of the fabric and relying too much on the dsa_to_port helper, use the new list of switch fabric ports to remap the Port VLAN Map of local bridge group members or remap the Port VLAN Table entry of external bridge group members. Signed-off-by: Vivien Didelot Reviewed-by: Florian Fainelli --- drivers/net/dsa/mv88e6xxx/chip.c | 39 +++++++++++++++----------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index af8943142053..826ae82ed727 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -2043,29 +2043,26 @@ static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port, static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip, struct net_device *br) { - struct dsa_switch *ds; - int port; - int dev; + struct dsa_switch *ds = chip->ds; + struct dsa_switch_tree *dst = ds->dst; + struct dsa_port *dp; int err; - /* Remap the Port VLAN of each local bridge group member */ - for (port = 0; port < mv88e6xxx_num_ports(chip); ++port) { - if (dsa_to_port(chip->ds, port)->bridge_dev == br) { - err = mv88e6xxx_port_vlan_map(chip, port); - if (err) - return err; - } - } - - /* Remap the Port VLAN of each cross-chip bridge group member */ - for (dev = 0; dev < DSA_MAX_SWITCHES; ++dev) { - ds = chip->ds->dst->ds[dev]; - if (!ds) - break; - - for (port = 0; port < ds->num_ports; ++port) { - if (dsa_to_port(ds, port)->bridge_dev == br) { - err = mv88e6xxx_pvt_map(chip, dev, port); + list_for_each_entry(dp, &dst->ports, list) { + if (dp->bridge_dev == br) { + if (dp->ds == ds) { + /* This is a local bridge group member, + * remap its Port VLAN Map. + */ + err = mv88e6xxx_port_vlan_map(chip, dp->index); + if (err) + return err; + } else { + /* This is an external bridge group member, + * remap its cross-chip Port VLAN Table entry. + */ + err = mv88e6xxx_pvt_map(chip, dp->ds->index, + dp->index); if (err) return err; } -- 2.23.0