Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp14828246rwd; Sun, 25 Jun 2023 05:17:14 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7oYmsV3XELIZoXQbHo9eY6lWZ1KI45bRFZadxTnqlvcMaPHwgLpG6DDM5707niGTtQPNgB X-Received: by 2002:a17:902:c407:b0:1b0:49e1:6dc4 with SMTP id k7-20020a170902c40700b001b049e16dc4mr2906466plk.56.1687695434580; Sun, 25 Jun 2023 05:17:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687695434; cv=none; d=google.com; s=arc-20160816; b=cGejYaxGywPKe3E+S+eX6SnUr1ECvKmNPUV95rhB7BwkxKToVvMMQ/WDkr/rc9qRCr tD6+9vWdr8ojY6aWbzQTneuV377p3eIW9nxeNIqi6pjv20gSIydMO0+8yc60qi/WUZO1 l/KbFR/fLfRdNbk/pelRnjEssOCUhN5wRDea2f75Bz0rgdc4in6vkbNjF7Zwrr1/12V2 GR67S2WF14x/r7IuFwBOEKUDkIth/3RixoJfPcGIuQ9Xq6sQjBHg+LGOrbIoZb6f7/R5 xu9sFUOetoFq1X1xYxjrP/Ui087+l6Ko/hLe7rjoqMBt5QJPX0A0jTVYzmICHdqEmhev 7OwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wsYPlWkKWx54UKPOm+m2MAyy1P9pH4wm4DWIQ7hUyQk=; fh=TDhZVPIxuB3SapFJ2cfry8UMhra0pONp3eDlzRMzdM4=; b=kWE3XK+SM7JA0ktxt+N3Rhh8e9FfDdilhcHQ/HWYWD8bfjEtUjd27kCTPoKqxpv4wS +Zn1tfIRhJLqcl+Bl6CnW1LUDGJGT5lwn9giYMY39DvQdu52wTn3ktswg25evCGWbe/O QYy4p8b0BL3WR+IdnZZaHDSZzq+wY1sPcVDUGdi58Sryi0kZvNIH3Jus3ktXmjpfP0oR Dy/8LKpokjMnZOPdIqOn0fr2Y0q3tGvG0FLAOAYB56zEIluoKbw4i8+rm/B3bP+qvB/2 UzgB32Hc18FkWRyGIE1s1ZpoaKD4qFlDxp9TqphnZbnr3ntglMTTD9wehnhYV7fywr61 tzvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=itKXmVf0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k12-20020a170902c40c00b001b382b2d2efsi3063957plk.28.2023.06.25.05.17.01; Sun, 25 Jun 2023 05:17:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=itKXmVf0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231949AbjFYLzP (ORCPT + 99 others); Sun, 25 Jun 2023 07:55:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231680AbjFYLy7 (ORCPT ); Sun, 25 Jun 2023 07:54:59 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3301EE45; Sun, 25 Jun 2023 04:54:55 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-4fafe87c6fbso552478e87.3; Sun, 25 Jun 2023 04:54:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687694093; x=1690286093; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wsYPlWkKWx54UKPOm+m2MAyy1P9pH4wm4DWIQ7hUyQk=; b=itKXmVf0xhP6VzvddpCCYnLfK/tjp7wyGswQxWjwGU83DT2ubn/z9kWl4FH74WCMrn M8ah1F5NX8gr4x4bFqn69m3zyuG0OSLngUw93/a7wgmRUzbhZBwOkBJUQRctLUWSyFmg bu1fNztbTsUNfhWHM5VfuHNzRPNrIeFT1xwCI2rCKsPG8q9wEvr6ScDGcSzR5emo7r20 Z6ewTQOfh29je93tMjeg8v6HjVy68cTe7EnuEQ3Hc2R7Qb3+a8k+8fb5i2GlLCXb2hUv LEbsbKjmM0CNRAUY1Rj1FUz1/PV5WVXWgb2GcqTkcx/wHmw+r9fW2ZmgrqUyQCA/2s1H CfRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687694093; x=1690286093; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wsYPlWkKWx54UKPOm+m2MAyy1P9pH4wm4DWIQ7hUyQk=; b=Ufr3JJ+vWMPGuknK6qjwZ3WRPfoFkUkNLyfY+fgBKHdI3iKonjARul+Q1ZpbQUWRZ7 SWehHfI0SGL2unpAVKsdlC6DVTE0gQwgCF2N5kQ1Ot+B+RFbfRuphKkeqYadsC1gTsEi PyHv8UkdoSnYIwLQTWByMUSLM5D6SXLmhiyH611gGt8AMQKRINQ7VDlEpbO84atJGNSt jwzU+HB+CQDY31l+4cRW0y2FXPkugCCeXJB3OSODhCP7/SuKpHAF9vmejDR5HeinGeib FJCYaI1guIiVb9CkwCS0mZqU4LlVfClZT9dvHapMj22ViUdCRfUgSdPHGTAQZTGmUao/ Jwhg== X-Gm-Message-State: AC+VfDx0/XA9PU8gXjp3KTTA2JJQmTKwUumJ4Ke+e7TKHAQFRBChQ0Db yupA8gRFQZeaJBryybXwJ/hg9abGjW6lKw== X-Received: by 2002:a05:6512:3e25:b0:4f9:70fe:d92a with SMTP id i37-20020a0565123e2500b004f970fed92amr4177442lfv.5.1687694093127; Sun, 25 Jun 2023 04:54:53 -0700 (PDT) Received: from WBEC325.dom.local ([185.188.71.122]) by smtp.gmail.com with ESMTPSA id w21-20020a2e9595000000b002b6993b9665sm416043ljh.65.2023.06.25.04.54.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Jun 2023 04:54:52 -0700 (PDT) From: Pawel Dembicki To: netdev@vger.kernel.org Cc: Pawel Dembicki , Linus Walleij , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 5/7] net: dsa: vsc73xx: Add bridge support Date: Sun, 25 Jun 2023 13:53:40 +0200 Message-Id: <20230625115343.1603330-5-paweldembicki@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230625115343.1603330-1-paweldembicki@gmail.com> References: <20230625115343.1603330-1-paweldembicki@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds bridge support for vsc73xx driver. It introduce two functions for port_bridge_join and vsc73xx_port_bridge_leave handling. Those functions implement forwarding adjust and use dsa_tag_8021q_bridge_* api for adjust VLAN configuration. Reviewed-by: Linus Walleij Signed-off-by: Pawel Dembicki --- v2: - no changes done drivers/net/dsa/vitesse-vsc73xx-core.c | 69 ++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/drivers/net/dsa/vitesse-vsc73xx-core.c b/drivers/net/dsa/vitesse-vsc73xx-core.c index f7c38f9a81a8..457eb7fddf4c 100644 --- a/drivers/net/dsa/vitesse-vsc73xx-core.c +++ b/drivers/net/dsa/vitesse-vsc73xx-core.c @@ -1304,6 +1304,72 @@ static int vsc73xx_vlan_set_pvid(struct dsa_switch *ds, int port, u16 vid, return 0; } +static void vsc73xx_update_forwarding_map(struct vsc73xx *vsc) +{ + int i; + + for (i = 0; i < vsc->ds->num_ports; i++) { + u32 val; + + vsc73xx_read(vsc, VSC73XX_BLOCK_ANALYZER, 0, + VSC73XX_SRCMASKS + i, &val); + /* update only if port is in forwarding state*/ + if (val & VSC73XX_SRCMASKS_PORTS_MASK) + vsc73xx_update_bits(vsc, VSC73XX_BLOCK_ANALYZER, 0, + VSC73XX_SRCMASKS + i, + VSC73XX_SRCMASKS_PORTS_MASK, + vsc->forward_map[i]); + } +} + +static int vsc73xx_port_bridge_join(struct dsa_switch *ds, int port, + struct dsa_bridge bridge, + bool *tx_fwd_offload, + struct netlink_ext_ack *extack) +{ + struct vsc73xx *vsc = ds->priv; + int i; + + *tx_fwd_offload = true; + + for (i = 0; i < ds->num_ports; i++) { + /* Add this port to the forwarding matrix of the + * other ports in the same bridge, and viceversa. + */ + if (!dsa_is_user_port(ds, i)) + continue; + + if (i == port) + continue; + + if (!dsa_port_offloads_bridge(dsa_to_port(ds, i), &bridge)) + continue; + + vsc->forward_map[port] |= VSC73XX_SRCMASKS_PORTS_MASK & BIT(i); + vsc->forward_map[i] |= VSC73XX_SRCMASKS_PORTS_MASK & BIT(port); + } + vsc73xx_update_forwarding_map(vsc); + + return dsa_tag_8021q_bridge_join(ds, port, bridge); +} + +static void vsc73xx_port_bridge_leave(struct dsa_switch *ds, int port, + struct dsa_bridge bridge) +{ + struct vsc73xx *vsc = ds->priv; + int i; + /*configure forward map to CPU <-> port only*/ + for (i = 0; i < vsc->ds->num_ports; i++) { + if (i == CPU_PORT) + continue; + vsc->forward_map[i] &= VSC73XX_SRCMASKS_PORTS_MASK & ~BIT(port); + } + vsc->forward_map[port] = VSC73XX_SRCMASKS_PORTS_MASK & BIT(CPU_PORT); + + vsc73xx_update_forwarding_map(vsc); + dsa_tag_8021q_bridge_leave(ds, port, bridge); +} + static int vsc73xx_tag_8021q_vlan_add(struct dsa_switch *ds, int port, u16 vid, u16 flags) { @@ -1342,6 +1408,7 @@ static int vsc73xx_setup(struct dsa_switch *ds) ds->vlan_filtering_is_global = false; ds->configure_vlan_while_not_filtering = false; + ds->max_num_bridges = 7; /* Issue RESET */ vsc73xx_write(vsc, VSC73XX_BLOCK_SYSTEM, 0, VSC73XX_GLORESET, @@ -1452,6 +1519,8 @@ static const struct dsa_switch_ops vsc73xx_ds_ops = { .get_sset_count = vsc73xx_get_sset_count, .port_enable = vsc73xx_port_enable, .port_disable = vsc73xx_port_disable, + .port_bridge_join = vsc73xx_port_bridge_join, + .port_bridge_leave = vsc73xx_port_bridge_leave, .port_change_mtu = vsc73xx_change_mtu, .port_max_mtu = vsc73xx_get_max_mtu, .port_stp_state_set = vsc73xx_port_stp_state_set, -- 2.34.1