From patchwork Thu Mar 18 14:15:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Waldekranz X-Patchwork-Id: 405353 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D660C4332B for ; Thu, 18 Mar 2021 14:17:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 41B7764EF9 for ; Thu, 18 Mar 2021 14:17:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231635AbhCROQi (ORCPT ); Thu, 18 Mar 2021 10:16:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231467AbhCROQP (ORCPT ); Thu, 18 Mar 2021 10:16:15 -0400 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76AEBC06175F for ; Thu, 18 Mar 2021 07:16:14 -0700 (PDT) Received: by mail-lj1-x229.google.com with SMTP id 15so7758980ljj.0 for ; Thu, 18 Mar 2021 07:16:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=waldekranz-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:organization:content-transfer-encoding; bh=kY/zRgZtVSmQ9x3rkAtUL3LZBddp1dUIHUnDZROHtsQ=; b=kgTthgNFqIuhbkq60fhMSYUKq/BD1H8bTEmDYLeQa9w+apMg1WR+am+y18VzDejyyr IHWkd4E6UjtNG9rytGVGhuBT4ceqDKEpAOsvs2xkYS7Pb4rVEkOE/7DjnF3cEAkVsm4U UuYMhGozN+vHOES+f5hAel0lzpDqDa9vjBIa8t3pVRVfDC3FCKJiz7xXUsidwvsXb7Oc C5qX7Le8a8fu9JdHy8VlvwAUXmo/80piDVsr9uRwhpdb/9YyOZLaaOM/b3K8p21B+w/U 7jlkryuZbZ7SXAuBu5xT29JXMDrWiq+q8RjEp+VnZsGlCQ/nbyf5RYOunoAI5sGa2Np6 9VJQ== 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:organization:content-transfer-encoding; bh=kY/zRgZtVSmQ9x3rkAtUL3LZBddp1dUIHUnDZROHtsQ=; b=YPSCZlyMGmvS2iCuJ/SPGDsDmOl8ime4um3SvWT0Gk0fxHUvQZmxKqwEV2L99SRvjr 0G60Rb10B4Bq9xAh0phWwjw0bG+K0UrSIItyI32X6OmKggMsRG5OuWQqBrOn7Wsqq/Cn nth5gMkExzgz6/8ITf3mIk6NidLbYXAaqyUnOn64s+hAbC+zMMVi6PWWi1yGgy1Re0jj qawE+YHeSeSkdr+jRDfCLKII+t8Yf13ojqccb3fSoY7lLQb//XSLbp5Wg77i3kaOTX7p atuJY9RiZBwrCNTtuFWvfOVQZxWuxiB0nrJycfhfIs40s6KqPxOnYN+SG1O27XtIwxit CmNw== X-Gm-Message-State: AOAM530YnZXhY4Ic1q8OGA54xyytzmlKLdIsQamHDJZvnvI/tYUmHrwu 5uv4Kz2k4pF2klM1ckWnFl3b7g== X-Google-Smtp-Source: ABdhPJy7sFJ8KWns8Xr966PWuqkpT+eNDqezumXhe/yVVOf5kxa/nEjbxcIG3Z8Gwq5AFxVYaqmaJQ== X-Received: by 2002:a2e:9d14:: with SMTP id t20mr5577231lji.391.1616076973024; Thu, 18 Mar 2021 07:16:13 -0700 (PDT) Received: from veiron.westermo.com (static-193-12-47-89.cust.tele2.se. [193.12.47.89]) by smtp.gmail.com with ESMTPSA id w26sm237382lfr.186.2021.03.18.07.16.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 07:16:12 -0700 (PDT) From: Tobias Waldekranz To: davem@davemloft.net, kuba@kernel.org Cc: andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, olteanv@gmail.com, netdev@vger.kernel.org Subject: [PATCH v2 net-next 1/8] net: dsa: Add helper to resolve bridge port from DSA port Date: Thu, 18 Mar 2021 15:15:43 +0100 Message-Id: <20210318141550.646383-2-tobias@waldekranz.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210318141550.646383-1-tobias@waldekranz.com> References: <20210318141550.646383-1-tobias@waldekranz.com> MIME-Version: 1.0 Organization: Westermo Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In order for a driver to be able to query a bridge for information about itself, e.g. reading out port flags, it has to use a netdev that is known to the bridge. In the simple case, that is just the netdev representing the port, e.g. swp0 or swp1 in this example: br0 / \ swp0 swp1 But in the case of an offloaded lag, this will be the bond or team interface, e.g. bond0 in this example: br0 / bond0 / \ swp0 swp1 Add a helper that hides some of this complexity from the drivers. Then, redefine dsa_port_offloads_bridge_port using the helper to avoid double accounting of the set of possible offloaded uppers. Signed-off-by: Tobias Waldekranz --- include/net/dsa.h | 14 ++++++++++++++ net/dsa/dsa_priv.h | 14 +------------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/include/net/dsa.h b/include/net/dsa.h index dac303edd33d..5c4340ecfeb2 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -493,6 +493,20 @@ static inline bool dsa_port_is_vlan_filtering(const struct dsa_port *dp) return dp->vlan_filtering; } +static inline +struct net_device *dsa_port_to_bridge_port(const struct dsa_port *dp) +{ + if (!dsa_is_user_port(dp->ds, dp->index)) + return NULL; + + if (dp->lag_dev) + return dp->lag_dev; + else if (dp->hsr_dev) + return dp->hsr_dev; + + return dp->slave; +} + typedef int dsa_fdb_dump_cb_t(const unsigned char *addr, u16 vid, bool is_static, void *data); struct dsa_switch_ops { diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h index 9d4b0e9b1aa1..4c43c5406834 100644 --- a/net/dsa/dsa_priv.h +++ b/net/dsa/dsa_priv.h @@ -233,19 +233,7 @@ extern const struct phylink_mac_ops dsa_port_phylink_mac_ops; static inline bool dsa_port_offloads_bridge_port(struct dsa_port *dp, struct net_device *dev) { - /* Switchdev offloading can be configured on: */ - - if (dev == dp->slave) - /* DSA ports directly connected to a bridge, and event - * was emitted for the ports themselves. - */ - return true; - - if (dp->lag_dev == dev) - /* DSA ports connected to a bridge via a LAG */ - return true; - - return false; + return dsa_port_to_bridge_port(dp) == dev; } static inline bool dsa_port_offloads_bridge(struct dsa_port *dp, From patchwork Thu Mar 18 14:15:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Waldekranz X-Patchwork-Id: 404594 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41FD2C4332D for ; Thu, 18 Mar 2021 14:17:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1C7D264E01 for ; Thu, 18 Mar 2021 14:17:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231624AbhCROQi (ORCPT ); Thu, 18 Mar 2021 10:16:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231499AbhCROQP (ORCPT ); Thu, 18 Mar 2021 10:16:15 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CE7FC061760 for ; Thu, 18 Mar 2021 07:16:15 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id u10so4841207lff.1 for ; Thu, 18 Mar 2021 07:16:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=waldekranz-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:organization:content-transfer-encoding; bh=ckpj5klz1A+5QoVk88jbrj3B/Q1ITN5QI5ibc65F/3Q=; b=Dr2ohKVrzk/q4TdAE5HHzBFKNrPaIyEK9VCEW1aW5/N2CXxsFIic2yb7nWDFQJoCIM mu8cfk0t9vIcP+IIWtI1mK9Y02feNZ3y9qbjHMlv+Bx1qD3NYxyqCjB9jDcZ0+8pgqZJ rFCLi4x80EhQEISNdTnnZluchS/SRFg8puNtwUqtXJ0P9yIUDI1pyFQdQjyvShxonPHK PFudz/WumV7w0v0cuNH5UiKbxHjLx2DAS6DhgF2d5/kFWisB3sjZgLHH0+WVAwYRM1MU 5wGqrPLjoMnc32lIjmRQMxWjsfvIadENFtyEN1i5SkY5APEUAigSvGqRlXE12etKCQmz Mrdw== 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:organization:content-transfer-encoding; bh=ckpj5klz1A+5QoVk88jbrj3B/Q1ITN5QI5ibc65F/3Q=; b=qXGzrfkWvHK4N3wAHqC5pJbofJBoC/Q/RPyqXd+/Y5GPohJMSEi/QO+hOCXb8wu15d zsX43nlhM5YQ7OPgjckm43Fw3xkS+J5XV5ZMsiNIkgvKZysZ06nlEixSc5BM107+bOyz a718MbxGcnlIZmDhotCOEIhyBuL9yFiC68k4kVIwcClnLYnIubWyvo4Uc7C8APJsI6GX rqJayiHbFqvyqIx6qwNQ32eIw4fL7fjtTl8uBcqqCY9Lh5l7e31yV4BWQXMDFmaHegfa RfkD9wInYMGHIo6XI8MiLLs67Ef8d1D3AQi63iugjbHUZJgqsq+foSIFAuCzbPfHlxYs dmiA== X-Gm-Message-State: AOAM530Obq1MZYZ9f4ou6lGZtnHGdWHaAKrCwr8eYBXqa/EgpXV5htuz GCBmmfXnvM0UYr+mh5B2MHdvLg== X-Google-Smtp-Source: ABdhPJxVIhPgP7fXlLTXJDpGu1OhIIRG3jE/Cut7RF2iPSHPBy17GC9PMVnK0o4YnV/5Y5K+7S+rHw== X-Received: by 2002:a19:4850:: with SMTP id v77mr5706486lfa.6.1616076973734; Thu, 18 Mar 2021 07:16:13 -0700 (PDT) Received: from veiron.westermo.com (static-193-12-47-89.cust.tele2.se. [193.12.47.89]) by smtp.gmail.com with ESMTPSA id w26sm237382lfr.186.2021.03.18.07.16.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 07:16:13 -0700 (PDT) From: Tobias Waldekranz To: davem@davemloft.net, kuba@kernel.org Cc: andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, olteanv@gmail.com, netdev@vger.kernel.org Subject: [PATCH v2 net-next 2/8] net: dsa: mv88e6xxx: Avoid useless attempts to fast-age LAGs Date: Thu, 18 Mar 2021 15:15:44 +0100 Message-Id: <20210318141550.646383-3-tobias@waldekranz.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210318141550.646383-1-tobias@waldekranz.com> References: <20210318141550.646383-1-tobias@waldekranz.com> MIME-Version: 1.0 Organization: Westermo Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When a port is a part of a LAG, the ATU will create dynamic entries belonging to the LAG ID when learning is enabled. So trying to fast-age those out using the constituent port will have no effect. Unfortunately the hardware does not support move operations on LAGs so there is no obvious way to transform the request to target the LAG instead. Instead we document this known limitation and at least avoid wasting any time on it. Signed-off-by: Tobias Waldekranz Reviewed-by: Vladimir Oltean Reviewed-by: Florian Fainelli --- drivers/net/dsa/mv88e6xxx/chip.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index f0a9423af85d..ed38b4431d74 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -1479,6 +1479,13 @@ static void mv88e6xxx_port_fast_age(struct dsa_switch *ds, int port) struct mv88e6xxx_chip *chip = ds->priv; int err; + if (dsa_to_port(ds, port)->lag_dev) + /* Hardware is incapable of fast-aging a LAG through a + * regular ATU move operation. Until we have something + * more fancy in place this is a no-op. + */ + return; + mv88e6xxx_reg_lock(chip); err = mv88e6xxx_g1_atu_remove(chip, 0, port, false); mv88e6xxx_reg_unlock(chip); From patchwork Thu Mar 18 14:15:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Waldekranz X-Patchwork-Id: 405349 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 089F5C4360C for ; Thu, 18 Mar 2021 14:17:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E6E4364F2A for ; Thu, 18 Mar 2021 14:17:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231656AbhCROQk (ORCPT ); Thu, 18 Mar 2021 10:16:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231527AbhCROQQ (ORCPT ); Thu, 18 Mar 2021 10:16:16 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D53C3C06174A for ; Thu, 18 Mar 2021 07:16:15 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id b83so4842628lfd.11 for ; Thu, 18 Mar 2021 07:16:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=waldekranz-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:organization:content-transfer-encoding; bh=btW31yi6BItpxQ7m00h0+TZYQwweUqbbSqt+hYCmyIE=; b=eJRQa6Cnu+zBrcLRxjykJugz3MYi/6mD39OlykAs2KSrEIvfKkVAKXrNTXj05mmPkl I/qxgSjUt8p3cMR901ilDvsJMsX2/j7x3T7Ae5pYOh81sJTj7hv4pacyWp5UndxwPiJV RGiKX8dIq3WmNX6QHtEpNjOGcf9y0awWO5sEslJ6Cd2ekSIt0a3z2zE/csxBc7bvIKHn iGOb34KPOm7wTXvz/ivyrncgI6mKzlqJtiee0MqbWE39C/sqsX1jz9HG6zOuMXcKtI6I gj6g44xZGyXjv5JjBccAz0P5oX5YeGfBskphH5tkLfP8dk7XgAhl1z8jCI8JVcPAHH8h +AXg== 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:organization:content-transfer-encoding; bh=btW31yi6BItpxQ7m00h0+TZYQwweUqbbSqt+hYCmyIE=; b=jPGrY5+4BnBHXyYmCoukgVoQ/JgKb+JMIRR4RXSgoEqeG6YWpDgmkQrVdWXya6XhDx 3Rt6BYJ4dWOO0dEkXqUydI4fKRIy2zymgXujdNmdEPIZUtka+Pu87Ax8SfYiTh7in6Bf J0j+6aDviT4fdqaH/iP9Mds71DENZt+Ah+E0oUf+VEaNHCfXju9DjGB+JU50/NEDVRGv JVrJnmuv45bjP4EwtbSiEF/kRSoBFeOSvXo9IM5E5aqMO6YHeQgbXwTidsooIF/eP0iT h4XHWrg8jtrinn3p7gdmpP3zgc21sJ1R7rgmogLyDkgLdHyadSWVUSyXBR0qMd0EDBkR jxZw== X-Gm-Message-State: AOAM53180tE8I7HOJm68dcT6FFXg7VWS6LyC0mZyzvUOAuiMKNBmDDbT wv/0MOmrbhkXGG4dPIPgMzniOw== X-Google-Smtp-Source: ABdhPJw0EsVcE1XGq3cEWR7QqezY2Y6bwwxPQohDakRqu+74tDK56i3aVgW+Ho6zAKIkmDu8Km2y1Q== X-Received: by 2002:ac2:5052:: with SMTP id a18mr5324091lfm.55.1616076974359; Thu, 18 Mar 2021 07:16:14 -0700 (PDT) Received: from veiron.westermo.com (static-193-12-47-89.cust.tele2.se. [193.12.47.89]) by smtp.gmail.com with ESMTPSA id w26sm237382lfr.186.2021.03.18.07.16.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 07:16:14 -0700 (PDT) From: Tobias Waldekranz To: davem@davemloft.net, kuba@kernel.org Cc: andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, olteanv@gmail.com, netdev@vger.kernel.org Subject: [PATCH v2 net-next 3/8] net: dsa: mv88e6xxx: Provide generic VTU iterator Date: Thu, 18 Mar 2021 15:15:45 +0100 Message-Id: <20210318141550.646383-4-tobias@waldekranz.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210318141550.646383-1-tobias@waldekranz.com> References: <20210318141550.646383-1-tobias@waldekranz.com> MIME-Version: 1.0 Organization: Westermo Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Move the intricacies of correctly iterating over the VTU to a common implementation. Signed-off-by: Tobias Waldekranz Reviewed-by: Andrew Lunn --- drivers/net/dsa/mv88e6xxx/chip.c | 100 ++++++++++++++++++++----------- 1 file changed, 64 insertions(+), 36 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index ed38b4431d74..0a4e467179c9 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -1511,6 +1511,37 @@ static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip, return chip->info->ops->vtu_getnext(chip, entry); } +static int mv88e6xxx_vtu_walk(struct mv88e6xxx_chip *chip, + int (*cb)(struct mv88e6xxx_chip *chip, + const struct mv88e6xxx_vtu_entry *entry, + void *priv), + void *priv) +{ + struct mv88e6xxx_vtu_entry entry = { + .vid = mv88e6xxx_max_vid(chip), + .valid = false, + }; + int err; + + if (!chip->info->ops->vtu_getnext) + return -EOPNOTSUPP; + + do { + err = chip->info->ops->vtu_getnext(chip, &entry); + if (err) + return err; + + if (!entry.valid) + break; + + err = cb(chip, &entry, priv); + if (err) + return err; + } while (entry.vid < mv88e6xxx_max_vid(chip)); + + return 0; +} + static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip, struct mv88e6xxx_vtu_entry *entry) { @@ -1520,9 +1551,18 @@ static int mv88e6xxx_vtu_loadpurge(struct mv88e6xxx_chip *chip, return chip->info->ops->vtu_loadpurge(chip, entry); } +static int mv88e6xxx_fid_map_vlan(struct mv88e6xxx_chip *chip, + const struct mv88e6xxx_vtu_entry *entry, + void *_fid_bitmap) +{ + unsigned long *fid_bitmap = _fid_bitmap; + + set_bit(entry->fid, fid_bitmap); + return 0; +} + int mv88e6xxx_fid_map(struct mv88e6xxx_chip *chip, unsigned long *fid_bitmap) { - struct mv88e6xxx_vtu_entry vlan; int i, err; u16 fid; @@ -1538,21 +1578,7 @@ int mv88e6xxx_fid_map(struct mv88e6xxx_chip *chip, unsigned long *fid_bitmap) } /* Set every FID bit used by the VLAN entries */ - vlan.vid = mv88e6xxx_max_vid(chip); - vlan.valid = false; - - do { - err = mv88e6xxx_vtu_getnext(chip, &vlan); - if (err) - return err; - - if (!vlan.valid) - break; - - set_bit(vlan.fid, fid_bitmap); - } while (vlan.vid < mv88e6xxx_max_vid(chip)); - - return 0; + return mv88e6xxx_vtu_walk(chip, mv88e6xxx_fid_map_vlan, fid_bitmap); } static int mv88e6xxx_atu_new(struct mv88e6xxx_chip *chip, u16 *fid) @@ -2198,10 +2224,30 @@ static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip, return err; } +struct mv88e6xxx_port_db_dump_vlan_ctx { + int port; + dsa_fdb_dump_cb_t *cb; + void *data; +}; + +static int mv88e6xxx_port_db_dump_vlan(struct mv88e6xxx_chip *chip, + const struct mv88e6xxx_vtu_entry *entry, + void *_data) +{ + struct mv88e6xxx_port_db_dump_vlan_ctx *ctx = _data; + + return mv88e6xxx_port_db_dump_fid(chip, entry->fid, entry->vid, + ctx->port, ctx->cb, ctx->data); +} + static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port, dsa_fdb_dump_cb_t *cb, void *data) { - struct mv88e6xxx_vtu_entry vlan; + struct mv88e6xxx_port_db_dump_vlan_ctx ctx = { + .port = port, + .cb = cb, + .data = data, + }; u16 fid; int err; @@ -2214,25 +2260,7 @@ static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port, if (err) return err; - /* Dump VLANs' Filtering Information Databases */ - vlan.vid = mv88e6xxx_max_vid(chip); - vlan.valid = false; - - do { - err = mv88e6xxx_vtu_getnext(chip, &vlan); - if (err) - return err; - - if (!vlan.valid) - break; - - err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port, - cb, data); - if (err) - return err; - } while (vlan.vid < mv88e6xxx_max_vid(chip)); - - return err; + return mv88e6xxx_vtu_walk(chip, mv88e6xxx_port_db_dump_vlan, &ctx); } static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port, From patchwork Thu Mar 18 14:15:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Waldekranz X-Patchwork-Id: 405351 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C58F5C432C3 for ; Thu, 18 Mar 2021 14:17:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AD0DF64EF9 for ; Thu, 18 Mar 2021 14:17:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231666AbhCROQl (ORCPT ); Thu, 18 Mar 2021 10:16:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231546AbhCROQQ (ORCPT ); Thu, 18 Mar 2021 10:16:16 -0400 Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D528C06174A for ; Thu, 18 Mar 2021 07:16:16 -0700 (PDT) Received: by mail-lj1-x231.google.com with SMTP id 16so7654237ljc.11 for ; Thu, 18 Mar 2021 07:16:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=waldekranz-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:organization:content-transfer-encoding; bh=bYs1Xthv5i1LFr+tljtLjYlXNiB00exl9DF7BJEJ/so=; b=l7hXwlqBw0IekkinPV1IrL8kMOUi52q46CYR4dB8RIn+b3xrYBDJYBYvNidv1oQYnS hOV/ymD5lKSp1Q4GN8a3ZiKljJv+Bj7Zp/tmpFIRzm8+2VAs3o23Fyb4n/LVt4ZzXHUA o43bHgV2DgmPleyfa+RBtjndGqCORrQcTYIe4l3txDpgwKtqItFVkq7wNG+BBBPaaO39 u7PHuCSEhwL4TncJsyKFbdZ0c+FdXZePqJiAQnngk5SNNNdje8qjGghDWLQG38veW81+ tcs8VtFLz6quexUgeSvkFcaaIl2uvHevAWBcAEW4sYaDI30wVhox5mWxrm1ijNHOxBIg 0tPw== 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:organization:content-transfer-encoding; bh=bYs1Xthv5i1LFr+tljtLjYlXNiB00exl9DF7BJEJ/so=; b=Dp5LNum13bIbfLPgwMk4QPEy1pe+bx77i6wYA37QlTYvqqfb6uwoQrP05MYOMWLCoy jVVeCSmnzWKLI+DKd3dF8XJTwX5OnzK/RZsBE6oA0Np0fvPb/l6IaYdADxppxI5Rzc4d kLwwqohti2f/sPOrwfJGL2QW/kx/vAYywFslVyFcPbx+6VtMPURmLbkiPHz0pjk1Kt0k yLZ6c5LCfOhZ4ItU8IFHNe9uJi4Q12d9eCSt8ni5B/YPiRbV91vKjkJQM68rsDpUvDqR 8GyrgFJ/eScYyNVneFkWmYTrVoeu7yVNkhREwL6fea+u8jwq24BJf7VnznCry89vS+qn klSQ== X-Gm-Message-State: AOAM533vhG0YsqXeHf6d5VV1sroJM7MNlAM6Q5LQrFysmUOnhQKdEJz5 wZhSPaPvt34d9rJbRkFKDMdzxQ== X-Google-Smtp-Source: ABdhPJzOccmt6RggYkbg94ODgFdyd+G0/CMsH92/o2CoBvA9qM+fmpZ2QW1Lzq1+4I3sBDyPH2hKfA== X-Received: by 2002:a2e:b537:: with SMTP id z23mr5343739ljm.350.1616076975037; Thu, 18 Mar 2021 07:16:15 -0700 (PDT) Received: from veiron.westermo.com (static-193-12-47-89.cust.tele2.se. [193.12.47.89]) by smtp.gmail.com with ESMTPSA id w26sm237382lfr.186.2021.03.18.07.16.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 07:16:14 -0700 (PDT) From: Tobias Waldekranz To: davem@davemloft.net, kuba@kernel.org Cc: andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, olteanv@gmail.com, netdev@vger.kernel.org Subject: [PATCH v2 net-next 4/8] net: dsa: mv88e6xxx: Remove some bureaucracy around querying the VTU Date: Thu, 18 Mar 2021 15:15:46 +0100 Message-Id: <20210318141550.646383-5-tobias@waldekranz.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210318141550.646383-1-tobias@waldekranz.com> References: <20210318141550.646383-1-tobias@waldekranz.com> MIME-Version: 1.0 Organization: Westermo Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The hardware has a somewhat quirky protocol for reading out the VTU entry for a particular VID. But there is no reason why we cannot create a better API for ourselves in the driver. Signed-off-by: Tobias Waldekranz --- drivers/net/dsa/mv88e6xxx/chip.c | 45 ++++++++++++++------------------ 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index 0a4e467179c9..c18c55e1617e 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -1502,13 +1502,23 @@ static int mv88e6xxx_vtu_setup(struct mv88e6xxx_chip *chip) return mv88e6xxx_g1_vtu_flush(chip); } -static int mv88e6xxx_vtu_getnext(struct mv88e6xxx_chip *chip, - struct mv88e6xxx_vtu_entry *entry) +static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid, + struct mv88e6xxx_vtu_entry *entry) { + int err; + if (!chip->info->ops->vtu_getnext) return -EOPNOTSUPP; - return chip->info->ops->vtu_getnext(chip, entry); + entry->vid = vid ? vid - 1 : mv88e6xxx_max_vid(chip); + entry->valid = false; + + err = chip->info->ops->vtu_getnext(chip, entry); + + if (entry->vid != vid) + entry->valid = false; + + return err; } static int mv88e6xxx_vtu_walk(struct mv88e6xxx_chip *chip, @@ -1615,19 +1625,13 @@ static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port, if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port)) return 0; - vlan.vid = vid - 1; - vlan.valid = false; - - err = mv88e6xxx_vtu_getnext(chip, &vlan); + err = mv88e6xxx_vtu_get(chip, vid, &vlan); if (err) return err; if (!vlan.valid) return 0; - if (vlan.vid != vid) - return 0; - for (i = 0; i < mv88e6xxx_num_ports(chip); ++i) { if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i)) continue; @@ -1709,15 +1713,12 @@ static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port, if (err) return err; } else { - vlan.vid = vid - 1; - vlan.valid = false; - - err = mv88e6xxx_vtu_getnext(chip, &vlan); + err = mv88e6xxx_vtu_get(chip, vid, &vlan); if (err) return err; /* switchdev expects -EOPNOTSUPP to honor software VLANs */ - if (vlan.vid != vid || !vlan.valid) + if (!vlan.valid) return -EOPNOTSUPP; fid = vlan.fid; @@ -1994,14 +1995,11 @@ static int mv88e6xxx_port_vlan_join(struct mv88e6xxx_chip *chip, int port, struct mv88e6xxx_vtu_entry vlan; int i, err; - vlan.vid = vid - 1; - vlan.valid = false; - - err = mv88e6xxx_vtu_getnext(chip, &vlan); + err = mv88e6xxx_vtu_get(chip, vid, &vlan); if (err) return err; - if (vlan.vid != vid || !vlan.valid) { + if (!vlan.valid) { memset(&vlan, 0, sizeof(vlan)); err = mv88e6xxx_atu_new(chip, &vlan.fid); @@ -2097,17 +2095,14 @@ static int mv88e6xxx_port_vlan_leave(struct mv88e6xxx_chip *chip, if (!vid) return -EOPNOTSUPP; - vlan.vid = vid - 1; - vlan.valid = false; - - err = mv88e6xxx_vtu_getnext(chip, &vlan); + err = mv88e6xxx_vtu_get(chip, vid, &vlan); if (err) return err; /* If the VLAN doesn't exist in hardware or the port isn't a member, * tell switchdev that this VLAN is likely handled in software. */ - if (vlan.vid != vid || !vlan.valid || + if (!vlan.valid || vlan.member[port] == MV88E6XXX_G1_VTU_DATA_MEMBER_TAG_NON_MEMBER) return -EOPNOTSUPP; From patchwork Thu Mar 18 14:15:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Waldekranz X-Patchwork-Id: 405352 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EBCEBC43619 for ; Thu, 18 Mar 2021 14:17:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D598864EF9 for ; Thu, 18 Mar 2021 14:17:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231678AbhCROQm (ORCPT ); Thu, 18 Mar 2021 10:16:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231556AbhCROQR (ORCPT ); Thu, 18 Mar 2021 10:16:17 -0400 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D24CC06174A for ; Thu, 18 Mar 2021 07:16:17 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id j11so4840372lfg.12 for ; Thu, 18 Mar 2021 07:16:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=waldekranz-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:organization:content-transfer-encoding; bh=Re8gOX+OB1Wzo+MBLWfqDrR9tfDJGKbyWNHNC47gGWs=; b=ithbiiLzxQz5TK3JF1/50ynztFUviotOliLAgfI2OCIif4f59kg+4jRZCk/Nf6csBi +v9nQxblYYCV4q6KFUvNOnPnf6fhF4/Nk0AjodjVAvz7UP6dT4Bmae2Ub7Qk5zLytept +rTuz297C+OZ0uB5ws+INJD+cGz9T3oIYbmtG+PC8jmrf7t5nn4jzpXOAT1jNYzH91/X WUpQ0us1A9bFleeYOUqXdnShLyKSVg8uvXbUGuchhdbCGvlb9lm8GbC63ALzCurAKITP 8iOXrsC+PqklVzU1h6oX1/sd+pssrB74K8Z8Nq8n+yy10yOkMBIlhZJNeH8wfMN76u/Y 3pEw== 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:organization:content-transfer-encoding; bh=Re8gOX+OB1Wzo+MBLWfqDrR9tfDJGKbyWNHNC47gGWs=; b=fAEqXOBiF35W3z9mG5oZDGUPysK2wywYHWr4BucD4CLOvswR3/eHxhoCf40pAUOwHT 3ZTKEgEHtwpuyT2RcaJBThloB35FL0ue4zkr32qyWbFdGe/XHgqL1CiKIo5GAPiBVfvs nA4qVCphJVLMygG5pOoMwQOyGN9oD4QT77mGHxFlS6bnYDxd4e4/i0H0NKkfW/hyjdK+ +8UVe3tbLSSBAqUDHnS1r/NL1DPmNGziv4+2sndSiUDva+Sae6pprtO2UWnsj0N0zrwD QRa6tnNhv2qbUnPOwyth8MafVBujIiK6cvoq40tEMeAsZBo3lNXrKdcIBVSGKLFBAWbA xqOQ== X-Gm-Message-State: AOAM531QU1rvmllxIvAKLDR4WXsUIUJWlErI7WtPvr0n3/iD9mvsixM5 1nO3zTFfluo1WpHImjInyNRiBw== X-Google-Smtp-Source: ABdhPJzX/v8yiaZk2QoVeH4CNWvKV0hlqwYmu98f1lGj+/CWuEwxJ0whUq5JczBeg5vusbh1WtavGQ== X-Received: by 2002:a05:6512:2117:: with SMTP id q23mr5479728lfr.423.1616076975700; Thu, 18 Mar 2021 07:16:15 -0700 (PDT) Received: from veiron.westermo.com (static-193-12-47-89.cust.tele2.se. [193.12.47.89]) by smtp.gmail.com with ESMTPSA id w26sm237382lfr.186.2021.03.18.07.16.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 07:16:15 -0700 (PDT) From: Tobias Waldekranz To: davem@davemloft.net, kuba@kernel.org Cc: andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, olteanv@gmail.com, netdev@vger.kernel.org Subject: [PATCH v2 net-next 5/8] net: dsa: mv88e6xxx: Use standard helper for broadcast address Date: Thu, 18 Mar 2021 15:15:47 +0100 Message-Id: <20210318141550.646383-6-tobias@waldekranz.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210318141550.646383-1-tobias@waldekranz.com> References: <20210318141550.646383-1-tobias@waldekranz.com> MIME-Version: 1.0 Organization: Westermo Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Use the conventional declaration style of a MAC address in the kernel (u8 addr[ETH_ALEN]) for the broadcast address, then set it using the existing helper. Signed-off-by: Tobias Waldekranz --- drivers/net/dsa/mv88e6xxx/chip.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index c18c55e1617e..17578f774683 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -1968,8 +1968,10 @@ static int mv88e6xxx_set_rxnfc(struct dsa_switch *ds, int port, static int mv88e6xxx_port_add_broadcast(struct mv88e6xxx_chip *chip, int port, u16 vid) { - const char broadcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; u8 state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC; + u8 broadcast[ETH_ALEN]; + + eth_broadcast_addr(broadcast); return mv88e6xxx_port_db_load_purge(chip, port, broadcast, vid, state); } From patchwork Thu Mar 18 14:15:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Waldekranz X-Patchwork-Id: 405347 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2E31C2BA1E for ; Thu, 18 Mar 2021 14:17:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9CD2464F24 for ; Thu, 18 Mar 2021 14:17:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231720AbhCROQs (ORCPT ); Thu, 18 Mar 2021 10:16:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229960AbhCROQT (ORCPT ); Thu, 18 Mar 2021 10:16:19 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53468C06175F for ; Thu, 18 Mar 2021 07:16:19 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id m17so4833872lfg.0 for ; Thu, 18 Mar 2021 07:16:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=waldekranz-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:organization:content-transfer-encoding; bh=QZ+BmjWfdM0TaLrjQBL3VVczhh71klPVNAd/B6Z/d/E=; b=gKg87iw5euuHYFfZPzktTVbW0SbOwNwJzt22HScVEopfckkDpPddTCQMM0mQq8zqi+ CFpXI3CrfNPb4k1gV7wXgFd8mSR0RaNUvN6yILKeppFMEfFVPQyUpX4zSNpbX2bDjXte kLuJYVfhOdOHMG/Ily/sJ2VeX4Eh6tj6r4RzJBzt5XXnbu6IL8T2d07C2g/fL4EXWByF 0QNY+nJ9GmHUlgEl8hMI4vD0l1Rtb11kWI34tyQTX9GwCywsDnb3QLs+otkDGgnzXcS+ q1XpKllBfiZaRIYOTHw02dP7Q3GqnkHQn9zOotARMD+nJFD6V9SIsv+/dgX738ltw9Qj r+ug== 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:organization:content-transfer-encoding; bh=QZ+BmjWfdM0TaLrjQBL3VVczhh71klPVNAd/B6Z/d/E=; b=gW59SvOFLZNgVqjBkx4azp/sZEV6Za/10HZvEWFX9ZBEOH9wTV+r9fQiKOWOovenUa P3SYLW8XEmKQ1HyjYuVP5YEzzEZ5eRbeGeVQ8LdWGlJZMrQj2xe6za69+0R6P0iS4ha9 YwrNvEbl4ErpiNvIXIwnZGpUfkjZUl/n+70DQMoaKIcQ4zXzwNWFAOvBhyATU/tFb7xc EWVlIzz6fMYp1mz4Xa0dMOMIvA0reJfd1qkvV1RsO8LG1WDY+Fnu1YFoIpDPP9p1ToPu ysU3X83AbgHNBXnmuOfE6F9rOybyUyuSY37fq3fOKOxIIDCMZ0s7MVJO8CnefOJ3kD/7 7Pwg== X-Gm-Message-State: AOAM533uASKQiFO7SP0XOUSemRx83Li24yamMaTaIf3hHOzTjvp3UwXM GvwKDEixsn/+ox2runyAvpNbLQ== X-Google-Smtp-Source: ABdhPJzSIAuiJCLen/D7VIMJpnJA3GzauNfZQmF9Bpa29iX25EOOfj68bTtHUTuk6NtnJ7+H8+3kuA== X-Received: by 2002:a05:6512:6c4:: with SMTP id u4mr5378868lff.289.1616076976344; Thu, 18 Mar 2021 07:16:16 -0700 (PDT) Received: from veiron.westermo.com (static-193-12-47-89.cust.tele2.se. [193.12.47.89]) by smtp.gmail.com with ESMTPSA id w26sm237382lfr.186.2021.03.18.07.16.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 07:16:15 -0700 (PDT) From: Tobias Waldekranz To: davem@davemloft.net, kuba@kernel.org Cc: andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, olteanv@gmail.com, netdev@vger.kernel.org Subject: [PATCH v2 net-next 6/8] net: dsa: mv88e6xxx: Flood all traffic classes on standalone ports Date: Thu, 18 Mar 2021 15:15:48 +0100 Message-Id: <20210318141550.646383-7-tobias@waldekranz.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210318141550.646383-1-tobias@waldekranz.com> References: <20210318141550.646383-1-tobias@waldekranz.com> MIME-Version: 1.0 Organization: Westermo Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In accordance with the comment in dsa_port_bridge_leave, standalone ports shall be configured to flood all types of traffic. This change aligns the mv88e6xxx driver with that policy. Previously a standalone port would initially not egress any unknown traffic, but after joining and then leaving a bridge, it would. This does not matter that much since we only ever send FROM_CPUs on standalone ports, but it seems prudent to make sure that the initial values match those that are applied after a bridging/unbridging cycle. Signed-off-by: Tobias Waldekranz Reviewed-by: Vladimir Oltean Reviewed-by: Florian Fainelli Reviewed-by: Andrew Lunn --- drivers/net/dsa/mv88e6xxx/chip.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index 17578f774683..587959b78c7f 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -2489,19 +2489,15 @@ static int mv88e6xxx_setup_message_port(struct mv88e6xxx_chip *chip, int port) static int mv88e6xxx_setup_egress_floods(struct mv88e6xxx_chip *chip, int port) { - struct dsa_switch *ds = chip->ds; - bool flood; int err; - /* Upstream ports flood frames with unknown unicast or multicast DA */ - flood = dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port); if (chip->info->ops->port_set_ucast_flood) { - err = chip->info->ops->port_set_ucast_flood(chip, port, flood); + err = chip->info->ops->port_set_ucast_flood(chip, port, true); if (err) return err; } if (chip->info->ops->port_set_mcast_flood) { - err = chip->info->ops->port_set_mcast_flood(chip, port, flood); + err = chip->info->ops->port_set_mcast_flood(chip, port, true); if (err) return err; } From patchwork Thu Mar 18 14:15:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Waldekranz X-Patchwork-Id: 404591 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A292C43142 for ; Thu, 18 Mar 2021 14:17:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 13AB264EF9 for ; Thu, 18 Mar 2021 14:17:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231710AbhCROQq (ORCPT ); Thu, 18 Mar 2021 10:16:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231558AbhCROQT (ORCPT ); Thu, 18 Mar 2021 10:16:19 -0400 Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92721C06174A for ; Thu, 18 Mar 2021 07:16:18 -0700 (PDT) Received: by mail-lj1-x232.google.com with SMTP id r20so7697067ljk.4 for ; Thu, 18 Mar 2021 07:16:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=waldekranz-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:organization:content-transfer-encoding; bh=EggvG2GyysNMviaqbbxN4WtDUlXGEfcdhFqI6EzPQ/M=; b=ledON4+hMRJ4TST81JzVc747fSTswlQfq1my37nzbLVP0GUfCU1GUyEZjwK/+FpasV 5Dlv72+NVPvLUqGV1XKWVGIbF4Y6AvTqrN3pD504IX/IyCVS0pK+eBS3eA1T4fOoQGZf cr92/r9zUtBNiwungnUB42pvVdXDHKd9+CIFPMf/PXGcxq0UCSNH3pjxzBNXwYuSmt8c WfI+dHKIMHHCO0sxl6fofjFQG1KgGLlVd2EOyfBPPKY8WRuRv7oqquA+bXc3EsNfUhsj 3GmluUZQZvbJpv3Q9WrtTMzzic76fvDrKP49+t3U8xp32Gs8XHm43RYY2yyHHlYDnG9E xxNg== 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:organization:content-transfer-encoding; bh=EggvG2GyysNMviaqbbxN4WtDUlXGEfcdhFqI6EzPQ/M=; b=nG7YG6XKrIweIAzRWqNNqOpEtbMNPZUq4ZvWx1s+v7v1nbx1sK63U5ejXpAqG5vyF2 qYypg86qRDXcfO7gUlD+aLS0VEHV6h40DxOxhy9EXUo9jM2AZVvEDlPfyr7gPHhWP0zQ 7NN7tqO8J3xZcV4nmWqjHdf60CWKFfsbWrMi3ZMnBmzbOiDE7NLLg2h+RAqzbPtL3CHO D7N89wW+NgBV6CkEsT/s8OHMGMn7UTVnMK9gBKaWnYrruc4bAvVZMPo7bNHV9TXmj+Pq zt/5N5qTRNPoJZGQySMSdqNq0mlftT/KSnCqYXMI+D40MVZay2RjU5Sa91t79tunGPMB AotQ== X-Gm-Message-State: AOAM533po0H8Xmrfmb3TlsTOMdrsdUaCztS2ae3AOq+LqVF4i68uSGGy VBK/Op2fB7M44gTaKBnJFN/lbw== X-Google-Smtp-Source: ABdhPJwXXniZQM+nPY2lNORK+ODHQc62irkJoeBGWcKvwA9NT0pKUXNdvvGvl7pjrVxYXfvchdhGig== X-Received: by 2002:a05:651c:303:: with SMTP id a3mr5245821ljp.290.1616076977134; Thu, 18 Mar 2021 07:16:17 -0700 (PDT) Received: from veiron.westermo.com (static-193-12-47-89.cust.tele2.se. [193.12.47.89]) by smtp.gmail.com with ESMTPSA id w26sm237382lfr.186.2021.03.18.07.16.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 07:16:16 -0700 (PDT) From: Tobias Waldekranz To: davem@davemloft.net, kuba@kernel.org Cc: andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, olteanv@gmail.com, netdev@vger.kernel.org Subject: [PATCH v2 net-next 7/8] net: dsa: mv88e6xxx: Offload bridge learning flag Date: Thu, 18 Mar 2021 15:15:49 +0100 Message-Id: <20210318141550.646383-8-tobias@waldekranz.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210318141550.646383-1-tobias@waldekranz.com> References: <20210318141550.646383-1-tobias@waldekranz.com> MIME-Version: 1.0 Organization: Westermo Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Allow a user to control automatic learning per port. Many chips have an explicit "LearningDisable"-bit that can be used for this, but we opt for setting/clearing the PAV instead, as it works on all devices at least as far back as 6083. Signed-off-by: Tobias Waldekranz Reviewed-by: Vladimir Oltean Reviewed-by: Florian Fainelli --- drivers/net/dsa/mv88e6xxx/chip.c | 37 +++++++++++++++++++++++++------- drivers/net/dsa/mv88e6xxx/port.c | 21 ++++++++++++++++++ drivers/net/dsa/mv88e6xxx/port.h | 2 ++ 3 files changed, 52 insertions(+), 8 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index 587959b78c7f..7976fb699086 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -2740,15 +2740,20 @@ static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port) return err; } - /* Port Association Vector: when learning source addresses - * of packets, add the address to the address database using - * a port bitmap that has only the bit for this port set and - * the other bits clear. + /* Port Association Vector: disable automatic address learning + * on all user ports since they start out in standalone + * mode. When joining a bridge, learning will be configured to + * match the bridge port settings. Enable learning on all + * DSA/CPU ports. NOTE: FROM_CPU frames always bypass the + * learning process. + * + * Disable HoldAt1, IntOnAgeOut, LockedPort, IgnoreWrongData, + * and RefreshLocked. I.e. setup standard automatic learning. */ - reg = 1 << port; - /* Disable learning for CPU port */ - if (dsa_is_cpu_port(ds, port)) + if (dsa_is_user_port(ds, port)) reg = 0; + else + reg = 1 << port; err = mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR, reg); @@ -5604,7 +5609,7 @@ static int mv88e6xxx_port_pre_bridge_flags(struct dsa_switch *ds, int port, struct mv88e6xxx_chip *chip = ds->priv; const struct mv88e6xxx_ops *ops; - if (flags.mask & ~(BR_FLOOD | BR_MCAST_FLOOD)) + if (flags.mask & ~(BR_LEARNING | BR_FLOOD | BR_MCAST_FLOOD)) return -EINVAL; ops = chip->info->ops; @@ -5623,10 +5628,23 @@ static int mv88e6xxx_port_bridge_flags(struct dsa_switch *ds, int port, struct netlink_ext_ack *extack) { struct mv88e6xxx_chip *chip = ds->priv; + bool do_fast_age = false; int err = -EOPNOTSUPP; mv88e6xxx_reg_lock(chip); + if (flags.mask & BR_LEARNING) { + bool learning = !!(flags.val & BR_LEARNING); + u16 pav = learning ? (1 << port) : 0; + + err = mv88e6xxx_port_set_assoc_vector(chip, port, pav); + if (err) + goto out; + + if (!learning) + do_fast_age = true; + } + if (flags.mask & BR_FLOOD) { bool unicast = !!(flags.val & BR_FLOOD); @@ -5648,6 +5666,9 @@ static int mv88e6xxx_port_bridge_flags(struct dsa_switch *ds, int port, out: mv88e6xxx_reg_unlock(chip); + if (do_fast_age) + mv88e6xxx_port_fast_age(ds, port); + return err; } diff --git a/drivers/net/dsa/mv88e6xxx/port.c b/drivers/net/dsa/mv88e6xxx/port.c index 6a9c45c2127a..f77e2ee64a60 100644 --- a/drivers/net/dsa/mv88e6xxx/port.c +++ b/drivers/net/dsa/mv88e6xxx/port.c @@ -1309,6 +1309,27 @@ int mv88e6097_port_egress_rate_limiting(struct mv88e6xxx_chip *chip, int port) 0x0001); } +/* Offset 0x0B: Port Association Vector */ + +int mv88e6xxx_port_set_assoc_vector(struct mv88e6xxx_chip *chip, int port, + u16 pav) +{ + u16 reg, mask; + int err; + + err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR, + ®); + if (err) + return err; + + mask = mv88e6xxx_port_mask(chip); + reg &= ~mask; + reg |= pav & mask; + + return mv88e6xxx_port_write(chip, port, MV88E6XXX_PORT_ASSOC_VECTOR, + reg); +} + /* Offset 0x0C: Port ATU Control */ int mv88e6xxx_port_disable_learn_limit(struct mv88e6xxx_chip *chip, int port) diff --git a/drivers/net/dsa/mv88e6xxx/port.h b/drivers/net/dsa/mv88e6xxx/port.h index 921d54969dad..b10e5aebacf6 100644 --- a/drivers/net/dsa/mv88e6xxx/port.h +++ b/drivers/net/dsa/mv88e6xxx/port.h @@ -407,6 +407,8 @@ int mv88e6165_port_set_jumbo_size(struct mv88e6xxx_chip *chip, int port, size_t size); int mv88e6095_port_egress_rate_limiting(struct mv88e6xxx_chip *chip, int port); int mv88e6097_port_egress_rate_limiting(struct mv88e6xxx_chip *chip, int port); +int mv88e6xxx_port_set_assoc_vector(struct mv88e6xxx_chip *chip, int port, + u16 pav); int mv88e6097_port_pause_limit(struct mv88e6xxx_chip *chip, int port, u8 in, u8 out); int mv88e6390_port_pause_limit(struct mv88e6xxx_chip *chip, int port, u8 in, From patchwork Thu Mar 18 14:15:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Waldekranz X-Patchwork-Id: 404590 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95936C4161F for ; Thu, 18 Mar 2021 14:17:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7711764EF9 for ; Thu, 18 Mar 2021 14:17:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231714AbhCROQr (ORCPT ); Thu, 18 Mar 2021 10:16:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231564AbhCROQT (ORCPT ); Thu, 18 Mar 2021 10:16:19 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CEE7C06174A for ; Thu, 18 Mar 2021 07:16:19 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id b83so4842966lfd.11 for ; Thu, 18 Mar 2021 07:16:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=waldekranz-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:organization:content-transfer-encoding; bh=bKcpC2dDbqfbjiG681wmb/mxrXsgkE1mtyFpi5i8rCY=; b=q9HLF0gL5YZkkvdeYLgSF8udx+Jm6FyH5//ahHrU2flf2mKZMsg9FihqGEiEF4Xs1B 0lZ4T0cSA2TKgdGirvjWrSxWDaX+CH3zFLRT6xqaa0bvYdlXkpe9IiS8pj1+LZ8p86cj V9EbBIS1nxLIFFI94F+U8I7b+LruhgMHNBwn0Hu6IiSi6RK8zDafDprLjTPOUt9P9YDH STn1V2iJ7kqEDdDS9KKHvKfS2RdxrMPhho+1Qt0M115pubKlufEu8uTgPHF6ucQ39iXx ZWx6r4Tui/VpcWJqSkhmX4YTgBhJPBCfkUVkmu780w3IvBSfOx1dgEyYmooLXRvHBOSa uqaQ== 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:organization:content-transfer-encoding; bh=bKcpC2dDbqfbjiG681wmb/mxrXsgkE1mtyFpi5i8rCY=; b=lWCGcQcjVM5hpZHSkVcFP5mi2+gzepYV922rYigNZ1jPZH/oGSqVKn1Du7kB409N/M fjibnyjO8vJPhPm4YkFO0MIcNoH9b7ICxYS5kBP72q+mnrtBylrEOpq9Vs10rEiw5yD1 CnRlV2fqX+fXj30+QjgZjs7ZD0+MXs+61h2Dzt5ikAbRn6WJQYBohU8HOznHOpUj9Bz+ DOpkCvqXXoXdyQzwYNPC5+JTLsSJqTwFoYgcdB1O/mcbdpE+ZaV2X1shIYUv2KZKNgoU FldnJ9UMbF2tuKm07swCOuwkLw4G5xZVEbpAxaBoygT8E7P147NAM4pBWZcBxmJgFfaK xD6w== X-Gm-Message-State: AOAM533O4inhlxfx56+2iEyRMQEH1zVkN2ivOsUrC92TgzCiXw8QnSVQ vMQsafrfExoa623drH9xhlIhHw== X-Google-Smtp-Source: ABdhPJyZRUTJswl6msc6OMqn7oPc5zZw2dBcbozRnRMKRN6Yf1ydT86a0nvaZO0ny8tWVHODLPjCmg== X-Received: by 2002:a19:ae0a:: with SMTP id f10mr5393048lfc.118.1616076977836; Thu, 18 Mar 2021 07:16:17 -0700 (PDT) Received: from veiron.westermo.com (static-193-12-47-89.cust.tele2.se. [193.12.47.89]) by smtp.gmail.com with ESMTPSA id w26sm237382lfr.186.2021.03.18.07.16.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 07:16:17 -0700 (PDT) From: Tobias Waldekranz To: davem@davemloft.net, kuba@kernel.org Cc: andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, olteanv@gmail.com, netdev@vger.kernel.org Subject: [PATCH v2 net-next 8/8] net: dsa: mv88e6xxx: Offload bridge broadcast flooding flag Date: Thu, 18 Mar 2021 15:15:50 +0100 Message-Id: <20210318141550.646383-9-tobias@waldekranz.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210318141550.646383-1-tobias@waldekranz.com> References: <20210318141550.646383-1-tobias@waldekranz.com> MIME-Version: 1.0 Organization: Westermo Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org These switches have two modes of classifying broadcast: 1. Broadcast is multicast. 2. Broadcast is its own unique thing that is always flooded everywhere. This driver uses the first option, making sure to load the broadcast address into all active databases. Because of this, we can support per-port broadcast flooding by (1) making sure to only set the subset of ports that have it enabled whenever joining a new bridge or VLAN, and (2) by updating all active databases whenever the setting is changed on a port. Signed-off-by: Tobias Waldekranz --- drivers/net/dsa/mv88e6xxx/chip.c | 73 +++++++++++++++++++++++++++++++- 1 file changed, 72 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index 7976fb699086..3baa4dadb0dd 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -1982,6 +1982,21 @@ static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid) int err; for (port = 0; port < mv88e6xxx_num_ports(chip); port++) { + struct dsa_port *dp = dsa_to_port(chip->ds, port); + struct net_device *brport; + + if (dsa_is_unused_port(chip->ds, port)) + continue; + + brport = dsa_port_to_bridge_port(dp); + + if (dp->bridge_dev && + !br_port_flag_is_set(brport, BR_BCAST_FLOOD)) + /* Skip bridged user ports where broadcast + * flooding is disabled. + */ + continue; + err = mv88e6xxx_port_add_broadcast(chip, port, vid); if (err) return err; @@ -1990,6 +2005,53 @@ static int mv88e6xxx_broadcast_setup(struct mv88e6xxx_chip *chip, u16 vid) return 0; } +struct mv88e6xxx_port_broadcast_sync_ctx { + int port; + bool flood; +}; + +static int +mv88e6xxx_port_broadcast_sync_vlan(struct mv88e6xxx_chip *chip, + const struct mv88e6xxx_vtu_entry *vlan, + void *_ctx) +{ + struct mv88e6xxx_port_broadcast_sync_ctx *ctx = _ctx; + u8 broadcast[ETH_ALEN]; + u8 state; + + if (ctx->flood) + state = MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC; + else + state = MV88E6XXX_G1_ATU_DATA_STATE_MC_UNUSED; + + eth_broadcast_addr(broadcast); + + return mv88e6xxx_port_db_load_purge(chip, ctx->port, broadcast, + vlan->vid, state); +} + +static int mv88e6xxx_port_broadcast_sync(struct mv88e6xxx_chip *chip, int port, + bool flood) +{ + struct mv88e6xxx_port_broadcast_sync_ctx ctx = { + .port = port, + .flood = flood, + }; + struct mv88e6xxx_vtu_entry vid0 = { + .vid = 0, + }; + int err; + + /* Update the port's private database... */ + err = mv88e6xxx_port_broadcast_sync_vlan(chip, &vid0, &ctx); + if (err) + return err; + + /* ...and the database for all VLANs. */ + return mv88e6xxx_vtu_walk(chip, mv88e6xxx_port_broadcast_sync_vlan, + &ctx); +} + static int mv88e6xxx_port_vlan_join(struct mv88e6xxx_chip *chip, int port, u16 vid, u8 member, bool warn) { @@ -5609,7 +5671,8 @@ static int mv88e6xxx_port_pre_bridge_flags(struct dsa_switch *ds, int port, struct mv88e6xxx_chip *chip = ds->priv; const struct mv88e6xxx_ops *ops; - if (flags.mask & ~(BR_LEARNING | BR_FLOOD | BR_MCAST_FLOOD)) + if (flags.mask & ~(BR_LEARNING | BR_FLOOD | BR_MCAST_FLOOD | + BR_BCAST_FLOOD)) return -EINVAL; ops = chip->info->ops; @@ -5663,6 +5726,14 @@ static int mv88e6xxx_port_bridge_flags(struct dsa_switch *ds, int port, goto out; } + if (flags.mask & BR_BCAST_FLOOD) { + bool broadcast = !!(flags.val & BR_BCAST_FLOOD); + + err = mv88e6xxx_port_broadcast_sync(chip, port, broadcast); + if (err) + goto out; + } + out: mv88e6xxx_reg_unlock(chip);