From patchwork Thu Mar 18 19:25:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Waldekranz X-Patchwork-Id: 12149087 X-Patchwork-Delegate: kuba@kernel.org 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 8FEE3C433E0 for ; Thu, 18 Mar 2021 19:26:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 60BF764F59 for ; Thu, 18 Mar 2021 19:26:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232764AbhCRT0V (ORCPT ); Thu, 18 Mar 2021 15:26:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232622AbhCRTZr (ORCPT ); Thu, 18 Mar 2021 15:25:47 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9DC1C06174A for ; Thu, 18 Mar 2021 12:25:46 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id e9so6738618wrw.10 for ; Thu, 18 Mar 2021 12:25:46 -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=LU4zHWVy6LHnH+mwS8aNnMWGy91irUuDZsXDy3cN124=; b=ohcxjnVa9vzDJDz6qWycoKQDPuSQ5EUkKA0tGjJmS3d9siotBIyCantCoTgNGRC6eU 8nz1aL+SSNwZGEBvbU030K9173YwBAu5TxwR02cMMdGpQXrOMrC1IlHr4JcpDxeZUt22 DVizI34+2/EQyGpUq7TRP5PnCvUV7drDom5rLGAprSDUPdaiIglL78LzZ61HEL04AFVH pGNbbGS66TwHBeJL7pLon8hYVmk4oVZ5VI033PLz+r2exRwPx8TSiCBDivbwB3Z4PwOE 1sVIUL8RRDaEhaveIEhjX11jQKqGQ2dSb7bI0vmnJ8s2qoUGXm7s6aN/bFxcgSJWVwra A8Ow== 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=LU4zHWVy6LHnH+mwS8aNnMWGy91irUuDZsXDy3cN124=; b=r9pg/Gx5nZroOYyvpNnK7B4OHkNXsVsmyjNnp9sbmscuMCltMXk0Qr7ySm5nTCfWq1 5Apln9V/JbOKw2f0HdYf4HakhWldFDXYQArHCNEvfpSgLJ31OaquiJdifyqW2hdWn/y5 JrN4fx6y6RlJaYj7qB3KJaTb5tKCgw3we/TXW59Nd6qinNSNKKgjuU1IuFZy5myZv1Hx 0fitd3D/VKx7jIeAje7YB0D5bO9kOHpU2h5bz+Ffb2/6/C4VAeW5S6rwkGRuE8KuoBPu Zx1CpmOG1um/9T03GFMJSeGZTlotcYCh2Xq/CqTZOfZmmXpNIfedXtifYCdRYr3mQBqb R/HA== X-Gm-Message-State: AOAM531JWsqI1XdWx9DC5g1QtcJgXOzQFTj1EUQjHGXf04WIBWcuJQ4f N+FVq01j6Lc4N5Ah3qU+ZiX/CA== X-Google-Smtp-Source: ABdhPJzgsnH/mD7Np/iPh36Q2KhP/IHDVGSRhKnSICIz6Zmt8uFKl/T7R1zwFNWan0rdFfqM5ZJ0pg== X-Received: by 2002:a5d:6ca6:: with SMTP id a6mr779299wra.179.1616095545650; Thu, 18 Mar 2021 12:25:45 -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 j30sm4576443wrj.62.2021.03.18.12.25.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 12:25:45 -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 v3 net-next 1/8] net: dsa: Add helper to resolve bridge port from DSA port Date: Thu, 18 Mar 2021 20:25:33 +0100 Message-Id: <20210318192540.895062-2-tobias@waldekranz.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210318192540.895062-1-tobias@waldekranz.com> References: <20210318192540.895062-1-tobias@waldekranz.com> MIME-Version: 1.0 Organization: Westermo Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@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 Reviewed-by: Vladimir Oltean Reviewed-by: Florian Fainelli --- 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..57b2c49f72f4 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 (!dp->bridge_dev) + 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 19:25:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Waldekranz X-Patchwork-Id: 12149089 X-Patchwork-Delegate: kuba@kernel.org 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 C165DC43381 for ; Thu, 18 Mar 2021 19:26:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8E0B064F6D for ; Thu, 18 Mar 2021 19:26:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232837AbhCRT0W (ORCPT ); Thu, 18 Mar 2021 15:26:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232642AbhCRTZs (ORCPT ); Thu, 18 Mar 2021 15:25:48 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE45EC06174A for ; Thu, 18 Mar 2021 12:25:47 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id k8so6731801wrc.3 for ; Thu, 18 Mar 2021 12:25:47 -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=y/jDzmJtmXJqAO2HChpQw77GavIlzk/eV/H2eZFxXgY=; b=AcP1KBPMCck6Pcb1LU3Eze1XS9aT4VZgp19ZdQzdSM9JrgH1VgbIH83EW62cKjAmSD rq8/veHdzuWf2f47ehBN9lFPa7PwCjSpCWWUYkh0rH+3aqr3uqzG9dmC5+pQMpnm63wQ 9rQnxSSjGqfX6oDG/RQgaiXU5m1ulVK+DjBHhaXPzsBdLNvpBa/PDOlWFDrdxTRhOkMa B1zUQvMct2bgyjyrbAL5eqIR680j4NdpdR4YJCumf8DxUU9BFd+Svq94kQ4hs0GwJ3aw ywiCMR+k59ulDe7tQG7op4Ae5y/0lNB7r3OFoZmU073zqHBqReva9W6n4BKX8hslBAsD 7zjA== 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=y/jDzmJtmXJqAO2HChpQw77GavIlzk/eV/H2eZFxXgY=; b=Al4jaOq6qIHMEut8LlbhL1DsFDCGwCZnfRYYWj1bVuZYHfbhq/wEaFd8BjvAf+kOL2 j0QeyCn4U7I2qLqeaAhyksSYwtrzIXjO+iZynkMB0Dg/ckjPMsxEypAjGEFxrcyQj0rO otGVOni3S6O43sxuI7VvzyFNNPH1QfNGLj8lmPoKeuJ3b9K56nE4hnEXqVIlVEBKlXGp q7UNOcH856tX4fRoiK2O9OYhn1n94rWW+hPGFCcaV+fra9+5XX4fRNWlthwZnBuAZaCN UMsgW5suvSkfx/oWlkhPdZ87i5RR8doiCw9TZaDNnE4SW95FSghXpK8Advdh3asoWk2W GJoA== X-Gm-Message-State: AOAM530sQSsMdwA1FK7Pkqmv0Y/Xz0hVlV2bTG3DHxRMGCZflcECfYZT zgGc9Z/km7UlzY1VNeEIVn44JA== X-Google-Smtp-Source: ABdhPJyf7ONLEmz/S/ZAol/ZNEYmbJOLQnGMUPNCeJWzosTeiHKQWAIhbEXxIc1llZOuYzwRR2rcig== X-Received: by 2002:adf:e5c4:: with SMTP id a4mr847069wrn.174.1616095546600; Thu, 18 Mar 2021 12:25:46 -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 j30sm4576443wrj.62.2021.03.18.12.25.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 12:25:46 -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 v3 net-next 2/8] net: dsa: mv88e6xxx: Avoid useless attempts to fast-age LAGs Date: Thu, 18 Mar 2021 20:25:34 +0100 Message-Id: <20210318192540.895062-3-tobias@waldekranz.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210318192540.895062-1-tobias@waldekranz.com> References: <20210318192540.895062-1-tobias@waldekranz.com> MIME-Version: 1.0 Organization: Westermo Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@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 19:25:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Waldekranz X-Patchwork-Id: 12149085 X-Patchwork-Delegate: kuba@kernel.org 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 B57A8C433E9 for ; Thu, 18 Mar 2021 19:26:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7AD0364F62 for ; Thu, 18 Mar 2021 19:26:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232856AbhCRT0Z (ORCPT ); Thu, 18 Mar 2021 15:26:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232680AbhCRTZt (ORCPT ); Thu, 18 Mar 2021 15:25:49 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEEA6C06174A for ; Thu, 18 Mar 2021 12:25:48 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id e18so6747019wrt.6 for ; Thu, 18 Mar 2021 12:25:48 -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=DuCZIg5au+dza1dRuyipKrYhx0/Zcv4kfypsdp2xTMU=; b=jzJL35Kouy6mqulnRuVeK/bnLuyFAxCiukQWWzg/MhmoO3K9OxAATzl2ZffEBfSAO6 I2ZFDmQpRMOakJm30UJTUIS9+RWB+dcfJycf/i24ufgMFdaVyCmWWdVlmvFLjQjmzDXQ 5E3CxhoPcNDVFR35KqS7VKyAYF0vamKRBGbD3yffFahdUqHZT+QWj6Ip91Qzi8Vp2uKe OosWug0zzn0qSgKcmENZ714Tm86PMH2++LpTVl5CTaBYpfGP1CLCVerYwPxsOBjnElCB q+BrZDSOIRklJasZS2nPn6Wwuz4/rRDHWYw6SyHG6K6wgFhcvCEQRaWrxuhTiBqfBQR4 G36g== 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=DuCZIg5au+dza1dRuyipKrYhx0/Zcv4kfypsdp2xTMU=; b=eZUq3P3HnsgYrp9nW2EV++sBckYjP4CESmwWUKqAP5dSUNEK29hkaJ6hX+QfRc+HaE arQbvgs3ZzGxGQA41BAAM0SMfiSxFwamqjF474cKjS3JAN+iZFNXsj6MB3bgQurqf69m yzCQwfNjLYY9HA6MQ0qi2RC8v4m3U8kDYtt6PJy+O0MGP9rI1yk6wvWAQ37A7kCnz0su DG80a1Spssj1K3h8rwbz1XkqZVObdlY7eWOF27j2Qt/QhdHt4lfsmbPlKpLMHD0If3ZW XmGyULKQiEgkvoemyleBz/VwAymd+/+bS4oHkOYUNHzOzaPSiNWN7EM4y3mugX3m1dML tXbA== X-Gm-Message-State: AOAM533SFKpmypQOKmuvRxM7vg59vDFiEmyOzMEdDzqFdpraFnG9Zs9J lv4ELZyvGHOIM0YXRbkHpW0q7A== X-Google-Smtp-Source: ABdhPJxa+LgDWoUwvWasKEj11uMV84A/OnD4SVg63er049iv1bMWlQ/4zAL2GvRf/72vV7W0WZcTeg== X-Received: by 2002:adf:f743:: with SMTP id z3mr830676wrp.304.1616095547483; Thu, 18 Mar 2021 12:25:47 -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 j30sm4576443wrj.62.2021.03.18.12.25.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 12:25:47 -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 v3 net-next 3/8] net: dsa: mv88e6xxx: Provide generic VTU iterator Date: Thu, 18 Mar 2021 20:25:35 +0100 Message-Id: <20210318192540.895062-4-tobias@waldekranz.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210318192540.895062-1-tobias@waldekranz.com> References: <20210318192540.895062-1-tobias@waldekranz.com> MIME-Version: 1.0 Organization: Westermo Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Move the intricacies of correctly iterating over the VTU to a common implementation. Signed-off-by: Tobias Waldekranz Reviewed-by: Andrew Lunn Reviewed-by: Vladimir Oltean Reviewed-by: Florian Fainelli --- 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 19:25:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Waldekranz X-Patchwork-Id: 12149097 X-Patchwork-Delegate: kuba@kernel.org 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 0FE9EC43332 for ; Thu, 18 Mar 2021 19:26:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A5A2E64F73 for ; Thu, 18 Mar 2021 19:26:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232865AbhCRT00 (ORCPT ); Thu, 18 Mar 2021 15:26:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232699AbhCRTZu (ORCPT ); Thu, 18 Mar 2021 15:25:50 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD7EDC06174A for ; Thu, 18 Mar 2021 12:25:49 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id j18so6744050wra.2 for ; Thu, 18 Mar 2021 12:25:49 -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=cizSHENUyeZGqFT7hDUldLiIWX9DfScZjIEGTfDRcWM=; b=Orn9ZHxdcm2Wx6ou2sEfH4ntpezmYyMaDYIDb/5Fe6tBA7bed0Amk2VKvEurkUdBwl FdmdyDSu5dDp90BFiA72Qt+8epGRZ/8gAB/0I47al26yrpyIAmOyxv8h1iLahx5o1qLk 3AWroWnJ8znqD6kXverKxMzEkTdk0+h+jVME4QxgHrGtuTKsNHzubFD8gh7bFi6nNQZT cqqjLBeqxDNjzxUcBTxSwda3PZGwMEc5K94+7152RbqRYEtN7KeEKd6XuFi68Wc1CRMy WlYFmfSl164/+3z65LDFwnwAxOVpD3IME3HlG2PDgHf3HnVEKigGIgiwhW57obPrre2o zh1A== 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=cizSHENUyeZGqFT7hDUldLiIWX9DfScZjIEGTfDRcWM=; b=ZzYKcnH08nb/vy51qoyEPeddUU2U8Bdb7xIpNvtx6L0D6C2z6mllmaRNWAvHrKd0rg sTXxIUlNGgivlWby0X6mA0MMvVPW0S7cOSfsr1ubttyf+xHbvTLUOOIJLJ36mrZz00N6 /MDZ8xjey4qYPDQtl2aKOlyNoQDwbo82LxJP0t/AQrfl0lSjrlbexY0NFyBLRBpdM4Ti 5LB9snh3ztRCcHEM6iHE+y6qH6d3Chk+ktLYFTcHy4wBxyJX0r15ScJKrqlcYlIZ/Oc2 0MpHrENyekNiHP1jMaJdePBNb1drm7QZ+pserdYaWG2PgM4aDQ3VatqV3ZMm9xSMrei8 LBlQ== X-Gm-Message-State: AOAM531ntobLt4mvKhrhkNP+F7nOehUwzewrAorMBw/35rFR8RaqWVp/ mz4++BRwHg8cCphNSwjh3F78c9bY7qeVDCNm X-Google-Smtp-Source: ABdhPJzc6BoZ/S43pTPtZ2E3brecGFBKnRL9TcCNVJYdiU7b6r3Ck7xSMrYN7aeSeXBsc/EXnhTyGw== X-Received: by 2002:adf:828e:: with SMTP id 14mr794902wrc.123.1616095548364; Thu, 18 Mar 2021 12:25:48 -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 j30sm4576443wrj.62.2021.03.18.12.25.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 12:25:48 -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 v3 net-next 4/8] net: dsa: mv88e6xxx: Remove some bureaucracy around querying the VTU Date: Thu, 18 Mar 2021 20:25:36 +0100 Message-Id: <20210318192540.895062-5-tobias@waldekranz.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210318192540.895062-1-tobias@waldekranz.com> References: <20210318192540.895062-1-tobias@waldekranz.com> MIME-Version: 1.0 Organization: Westermo Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@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 Reviewed-by: Vladimir Oltean Reviewed-by: Florian Fainelli --- 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 19:25:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Waldekranz X-Patchwork-Id: 12149099 X-Patchwork-Delegate: kuba@kernel.org 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 182B7C43331 for ; Thu, 18 Mar 2021 19:26:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C3DBD64F78 for ; Thu, 18 Mar 2021 19:26:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232887AbhCRT02 (ORCPT ); Thu, 18 Mar 2021 15:26:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230008AbhCRTZu (ORCPT ); Thu, 18 Mar 2021 15:25:50 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79EA2C06174A for ; Thu, 18 Mar 2021 12:25:50 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id x16so6740201wrn.4 for ; Thu, 18 Mar 2021 12:25:50 -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=zP0kBsVM+1TTrok+2Mhmew5SesmqBzk0gDKAfV3ffqs=; b=g3H5yuch4EXsJnSjGflpLOXhkwIXc108yJhaTZEpHaAsSWbaQEIMiB0hIHtGpZ70Er XoFbCsy1ftQZ/mnf/eLRzZYlxSuytSSauvPvuHa5LF9sp9SRfwEafhYqdDaf7H7qBAr3 nHFyhEJMrFW2p+2Mi9q5yp+wjAyH7afKk+slQhLP/7oOeVDGwWwGXWhOYsvmgpmcBYP0 Ha7gfjND1SV8M0cvstVau+4PWgjeXtXW9A1Pw6RhkEJbD6pxxLMJ/d0CZZ4stEnDsjht nVKfwj/ANOLjxur5DwecFl4hzOEssAPVObOQBBgsBUY9m1MwfCq2t4N7+Gc3n/Ro9ejA fEBQ== 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=zP0kBsVM+1TTrok+2Mhmew5SesmqBzk0gDKAfV3ffqs=; b=FJ4XJq39e/cmxGuoFSzwPqoTL3kehBvX4nS3Fm5sw5744eazyMJ5kmtJpt1hj+c/Sw iVCI/H/+ArXsPe2sRvyCyv4vlsoTRpY1LiuHgCjGpsJzs04iEzwtOHPG6hwkujOep2+Z mVnHIkVp3qcGqfY4gBaRTVRHFf0UWr39kQU8hk+8JAm5ypmaAAM0uhqSZMlUnI31ihBz SRQhJUUxWNFcyQj0t/NbUkurZKWB3tbToJRfWEl9tVrwNFnKmW5whc3FqKMpj/Mxw35b tl1X+92TW0xzqn6hmRERkJm7rs5nBAi6i+1BaXbw9eiTr7uEpf891co0pgMo4a2hcJxO 1Qog== X-Gm-Message-State: AOAM531kSlvvk8k79Hd8LkcWO+eScRvPoR1fe6Zb4wQlWQn5VjMENaq0 c7wnIRiaMXcVMd61WcLRP5ECRA== X-Google-Smtp-Source: ABdhPJyAwgg3Bedt3PfOVmR4pLZ9uI9UFilerbmJdSSjDkgh3RTLjK0NFc3MI1v6kHLfa6bDWBLCrw== X-Received: by 2002:adf:e391:: with SMTP id e17mr777881wrm.285.1616095549274; Thu, 18 Mar 2021 12:25:49 -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 j30sm4576443wrj.62.2021.03.18.12.25.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 12:25:49 -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 v3 net-next 5/8] net: dsa: mv88e6xxx: Use standard helper for broadcast address Date: Thu, 18 Mar 2021 20:25:37 +0100 Message-Id: <20210318192540.895062-6-tobias@waldekranz.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210318192540.895062-1-tobias@waldekranz.com> References: <20210318192540.895062-1-tobias@waldekranz.com> MIME-Version: 1.0 Organization: Westermo Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@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 Reviewed-by: Vladimir Oltean Reviewed-by: Florian Fainelli --- 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 19:25:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Waldekranz X-Patchwork-Id: 12149093 X-Patchwork-Delegate: kuba@kernel.org 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 C9FE9C4332D for ; Thu, 18 Mar 2021 19:26:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B52FB64F59 for ; Thu, 18 Mar 2021 19:26:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232878AbhCRT02 (ORCPT ); Thu, 18 Mar 2021 15:26:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231590AbhCRTZv (ORCPT ); Thu, 18 Mar 2021 15:25:51 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60D7EC06174A for ; Thu, 18 Mar 2021 12:25:51 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id e9so6738814wrw.10 for ; Thu, 18 Mar 2021 12:25:51 -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=oZRszZh708TywdWKoT9dYHSwsPOizUQJlWXqlJSV2Yf/KWhxAo/LO0a//IKwA5cQdb IOfZTahkkSP6V7toUsLBhYJLPnPVFw+4AqUwi4gDzE2l1Apx91ExS6fAqWn953QzN2Z8 urocdEDCJVPneCi9PpGMxHFKUj5JCK/FEsYSq3gG0f77a0yd8vVLeNmdorHkDPhVypE4 tTsJV/KsO1RxljJ8ZDZkQBpBa2h31P/DCFFur3vDZAgeM7iQaEEw5Zx79M6BlFUA8yhN 5hLYtMII9SDbhzUbwXVqWDiKHQoCchaXV7SCVqlJThtAYDzn7ICd6ekPHfU81aVXbmox vqug== 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=LRgttiY1MBzx0Z3y5VTSwu32oRY3nQ5m6CxH1BVbARYtQvo9t01ihkeiD0A+X9hdWt mkAHqzO2hvfOtL/llP/ATZHmeRofkDmUeIHsf/D48zIOHOfvWlELjZqHeGDmjz4CXf8I duXDO7DWqF32FxfyDLrc8ffTApHjpffBC2zrxQjhxo2GJ+Rztx7Closb2MCfaKJ5ZEm1 L3LcR2q/nx87qOFzhFFnNc2Ez/RLiT9Pzux5DT+lq+NY1q0AOJRLjX/APgTUDIl+b1b3 LhIHYiZ+7wiKbnDvfsTipo5sHF4g0CfATHi+yU419jC+Wv6Z3Thp2VGxTVIXumKDAYDS 8Qig== X-Gm-Message-State: AOAM533Tjx7DcbZNkoAhEd8yrbsd4UNV4OF4GKax7v6T3XEK40JVJMif ubxY4gbLG8Nmw9hCzM5tZLdG6Q== X-Google-Smtp-Source: ABdhPJznYX9RkbhQyYd0cr4VcfItXggLpZOExwvNuEJwv9rAsP+bpot0u+5V3U2HYNKAra71nldUEw== X-Received: by 2002:adf:f4c1:: with SMTP id h1mr810896wrp.71.1616095550160; Thu, 18 Mar 2021 12:25:50 -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 j30sm4576443wrj.62.2021.03.18.12.25.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 12:25:49 -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 v3 net-next 6/8] net: dsa: mv88e6xxx: Flood all traffic classes on standalone ports Date: Thu, 18 Mar 2021 20:25:38 +0100 Message-Id: <20210318192540.895062-7-tobias@waldekranz.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210318192540.895062-1-tobias@waldekranz.com> References: <20210318192540.895062-1-tobias@waldekranz.com> MIME-Version: 1.0 Organization: Westermo Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@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 19:25:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Waldekranz X-Patchwork-Id: 12149091 X-Patchwork-Delegate: kuba@kernel.org 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 E7B2EC4332E for ; Thu, 18 Mar 2021 19:26:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D4E8564F62 for ; Thu, 18 Mar 2021 19:26:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232897AbhCRT0a (ORCPT ); Thu, 18 Mar 2021 15:26:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232786AbhCRTZw (ORCPT ); Thu, 18 Mar 2021 15:25:52 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45C0FC06174A for ; Thu, 18 Mar 2021 12:25:52 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id 12so4236300wmf.5 for ; Thu, 18 Mar 2021 12:25:52 -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=/wrMZdOtl5sD86qNaeMp5aHyUUC7Lzc7w71/3Uf5ti0=; b=rjuxs2RmOIFSyURa0DZ4isFVhcyfnCSAQtin4FgwpeABXpAqOm6uL9uK9iy71vBzn0 TJbobinNumjm4NzGjbshIK/vGgyZSUCNY9q3B8RqiJ4jRr8/thzDDk5i9Bv2976Tgoof Bym52eEs66PJv+XTWB/FWmvokvueAPQQVX6Imibmod0f6KX9JGTaSMaegBtSKI1Ysbyp OtwhVRPsd+klmyDR6BiBKSY0fhPxZsgyXE/toAQmtCzYcJrB772QSPWuQE0OatoKXb8O 9WWW/dYibCybQ6QpCeMDAQQXzBdgdiKgN/UVnI4bq93HrQBMwyt6N5dRB1jyroSFd68F g0bA== 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=/wrMZdOtl5sD86qNaeMp5aHyUUC7Lzc7w71/3Uf5ti0=; b=uVY8h7i1aUd02aNRwBtIDud+zwQsAVWN6kL4rpsR4g1f5LId1ymeI/si/0aYXqBM7R W7Iw7yb4xxe6kQ+6nBy/BOJpgLcn6JcX4e2Pxj9aVqp75BGC64aemLh9DTM3nL/xc4SP nZCNcwMFRWeA/Cn3yzXnSkRkRlUYtvHVAQSXWPUp1eIB4+WDELwwduttmQ511lEjJ+/H xqJxkSiumNv48/pOxorfgsixvvfaCyZCcFE8i5z7e0GgLqMXpAS4L0sCopo3/blYVKTz kAR2cN48IavIF/cv8l0WQMEupYqF0gENb+suaCVgyhLxwC6DyzZwa//9uChRCUG6HHyP 2oYQ== X-Gm-Message-State: AOAM532w9BHQbkpLIqdL7m1d7YLfLJphokPnDD3MecEfpl2UNqKVxjXr E6Wg/mY3f38gY/iy4jZg7HYY7A== X-Google-Smtp-Source: ABdhPJxZwxr/ciE6RLy7XcFPXbYkHG+Shvu8UX5PhnoaEvSDrql8yaaVhavvx/Lrx+Mrz35d7e7JDg== X-Received: by 2002:a05:600c:4305:: with SMTP id p5mr641862wme.58.1616095551038; Thu, 18 Mar 2021 12:25:51 -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 j30sm4576443wrj.62.2021.03.18.12.25.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 12:25:50 -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 v3 net-next 7/8] net: dsa: mv88e6xxx: Offload bridge learning flag Date: Thu, 18 Mar 2021 20:25:39 +0100 Message-Id: <20210318192540.895062-8-tobias@waldekranz.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210318192540.895062-1-tobias@waldekranz.com> References: <20210318192540.895062-1-tobias@waldekranz.com> MIME-Version: 1.0 Organization: Westermo Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@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 19:25:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Waldekranz X-Patchwork-Id: 12149095 X-Patchwork-Delegate: kuba@kernel.org 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 0B9AFC4332B for ; Thu, 18 Mar 2021 19:26:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E5E7B64F57 for ; Thu, 18 Mar 2021 19:26:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232892AbhCRT03 (ORCPT ); Thu, 18 Mar 2021 15:26:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232802AbhCRTZx (ORCPT ); Thu, 18 Mar 2021 15:25:53 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54C55C06175F for ; Thu, 18 Mar 2021 12:25:53 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id 12so4236323wmf.5 for ; Thu, 18 Mar 2021 12:25:53 -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=VqQsQdax3O/Z0p8kDLBVJ5i6JwBjqgRFd6jB/taEUBg=; b=uA1pUvcYXeSSSyCG/JnK5V+MAmwkIRjkDK9mfTl69D1kX2+Wc6UGTYDDCGGI305yQu cgrAGcnm3bh6E8zrtSqHf3jBZns2eCDEtNE3yC2diYgKkNoO7NKyiVikKxQTBcCo1S4V 768tHp6C6EXd/aDsQvceFY7jaCx7Ry/6+aWFguYuOlpx9Jtzt85fC/vhvqaLWFimqZcf V93us555WtDXdYDcfYS6kLp4zvnLGtXRI7yL1Z/CerVlyoPWS/srjVsmtcGEKB5cRVUT fDI3ZPnBqkXNE3F2lbMJDTyCLC8UFtrGerVGfIkWHeYQWz/CTN4XQMnOJNok9PDgS9zr gHQA== 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=VqQsQdax3O/Z0p8kDLBVJ5i6JwBjqgRFd6jB/taEUBg=; b=uhphmYfBjZ19xasHp/2Tdl1kryb3uxLTrFVBArqOZtTuGCrMLmvKqSpV7LqgHgQs0B OVusWZiFBSuki5j6lRb3S8yDT5rEsVc4K+MnVUGa0HAvxJIWMW+kXyZhaRQabhUbBxow KJbRdHsMR+Sj5GiAmPfOii/XZJnnrXFfMQLisH+QCk1+lYrgj+uHhqA0se8JPIhbYNv/ hnPfCkriQWgJ6GDysjKS2q8u+/U7Sir9NS2fPwaabU68qRSDQZZYe+J1yqCX87+/+Gmf ioKKorPesFyUAVD7gNu5oWewY9FXoRYvArtt9SnlJYF1Rsqsz6+vgwbgZMNX9pbXHtAv UqOg== X-Gm-Message-State: AOAM5324/8mX4jXZwETwLlowjgNMMnIhBqXgkQ3hD5BC3oyWy3hQrBEv Am6q5bX+5cQaYr0xrRCyNgJYfA== X-Google-Smtp-Source: ABdhPJy9yWoLSYz3GCvpNT0dg8FdaCQj17oHcqQKfEElF8nGPBMXSbqR1MBtrw1A5bOZ2rp+grkmaQ== X-Received: by 2002:a1c:ac02:: with SMTP id v2mr8708wme.111.1616095552035; Thu, 18 Mar 2021 12:25:52 -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 j30sm4576443wrj.62.2021.03.18.12.25.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 12:25:51 -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 v3 net-next 8/8] net: dsa: mv88e6xxx: Offload bridge broadcast flooding flag Date: Thu, 18 Mar 2021 20:25:40 +0100 Message-Id: <20210318192540.895062-9-tobias@waldekranz.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210318192540.895062-1-tobias@waldekranz.com> References: <20210318192540.895062-1-tobias@waldekranz.com> MIME-Version: 1.0 Organization: Westermo Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@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 Reviewed-by: Florian Fainelli --- drivers/net/dsa/mv88e6xxx/chip.c | 71 +++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index 7976fb699086..95f07fcd4f85 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -1982,6 +1982,19 @@ 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 (brport && !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 +2003,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 +5669,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 +5724,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);