From patchwork Fri Jun 18 18:30:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12332009 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 178ACC49361 for ; Fri, 18 Jun 2021 18:30:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F198A613ED for ; Fri, 18 Jun 2021 18:30:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235016AbhFRScu (ORCPT ); Fri, 18 Jun 2021 14:32:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233577AbhFRSco (ORCPT ); Fri, 18 Jun 2021 14:32:44 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55F6AC06175F for ; Fri, 18 Jun 2021 11:30:32 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id t3so9853832edc.7 for ; Fri, 18 Jun 2021 11:30:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mdGI9KdhxE1M65wlF6EhJcVpZobBKGasuvbTwE7j2TM=; b=Z2KLDrEOrNyPy4fVcDgr6FK1ZZoHu5MwWeesaGQrlWAM8cQSErjucWWlEWrxUnsLkO 0owQ9htX1Ds46X+XEo+QPIg5lLA/Kq51cDxmXr0oylRteNgrjF2oYpKwresCZDcxVQxW LDHnWhbhYx2kT4w09Z8+1F+WHwd8qkuyje2RYzek58Y/+kSzPa9EvURH3ssDWwcbJKoD enmuOhkcOrwQozvGgId7Mz9I7Bb8XrMKNb0QrM/r2JSndjm3HYmKbzCJ9YVFImXf+YZU ibuqdZEYHjQuhP5znOxRCeU/UgyyvXrAEFitwt2FpO5cTCAvUwfjOf6vftgrf5cbclLm AqmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mdGI9KdhxE1M65wlF6EhJcVpZobBKGasuvbTwE7j2TM=; b=ite05xi0plGRMHowsAaQmNt8tvU/u5aRGBV96kGSG9BU0vxRVWi7Ui/LVR3kO9JQLw V23AMf9v+vax+tswGeDTR0y4QIlI/sxU2+SNqsnb4+4fdnzSHJ+MszR4GpBRQ1PPpQYa t6M0Qq5/+X+rOTUP+FPFCG+7DNhQ/jbOCwm5LG9gy9lYtz2drUFccQAST3vT/9A8RNJs fFwkecYQgvXwl4nCsyvhOCG5TnVQlGgz2vm02F63xe/TcnXkNnqHL17rYdLskS6GEWrQ oJmAtRS67fx/FzGOhC4N0pYTc0ApseO+6WNCsbsFhsMoYEVQ2R+D6+s4+Hd2aSMdFMG1 74TA== X-Gm-Message-State: AOAM531Ui8SjkMmLPGDmYXdhCXLe1SjkANtBf4LudvdsrqEcqLH+06KJ 9iVpHs8gEmX3IYPv5vyAh9Y= X-Google-Smtp-Source: ABdhPJxm6aEJ3GXnGHpJyHmSWQCk+EVqzPsb6T04MhlByWNXdV6XQIqLPQRNyoSQNdMLhrYOErK/9g== X-Received: by 2002:a05:6402:51d0:: with SMTP id r16mr7201541edd.138.1624041030945; Fri, 18 Jun 2021 11:30:30 -0700 (PDT) Received: from localhost.localdomain ([188.26.224.68]) by smtp.gmail.com with ESMTPSA id s11sm6071988edd.65.2021.06.18.11.30.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:30:30 -0700 (PDT) From: Vladimir Oltean To: Jakub Kicinski , "David S. Miller" , netdev@vger.kernel.org Cc: Florian Fainelli , Andrew Lunn , Vivien Didelot , Vladimir Oltean Subject: [PATCH net-next 1/6] net: dsa: assert uniqueness of dsa,member properties Date: Fri, 18 Jun 2021 21:30:12 +0300 Message-Id: <20210618183017.3340769-2-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618183017.3340769-1-olteanv@gmail.com> References: <20210618183017.3340769-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Vladimir Oltean The cross-chip notifiers work by comparing each ds->index against the info->sw_index value from the notifier. The ds->index is retrieved from the device tree dsa,member property. If a single tree cross-chip topology does not declare unique switch IDs, this will result in hard-to-debug issues/voodoo effects such as the cross-chip notifier for one switch port also matching the port with the same number from another switch. Check in dsa_switch_parse_member_of() whether the DSA switch tree contains a DSA switch with the index we're preparing to add, before actually adding it. Signed-off-by: Vladimir Oltean Reviewed-by: Florian Fainelli Reviewed-by: Andrew Lunn --- net/dsa/dsa2.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index b71e87909f0e..ba244fbd9646 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -1259,6 +1259,13 @@ static int dsa_switch_parse_member_of(struct dsa_switch *ds, if (!ds->dst) return -ENOMEM; + if (dsa_switch_find(ds->dst->index, ds->index)) { + dev_err(ds->dev, + "A DSA switch with index %d already exists in tree %d\n", + ds->index, ds->dst->index); + return -EEXIST; + } + return 0; } From patchwork Fri Jun 18 18:30:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12332011 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 1318EC48BE8 for ; Fri, 18 Jun 2021 18:30:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F1560613ED for ; Fri, 18 Jun 2021 18:30:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235084AbhFRScv (ORCPT ); Fri, 18 Jun 2021 14:32:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233870AbhFRScp (ORCPT ); Fri, 18 Jun 2021 14:32:45 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B794C061767 for ; Fri, 18 Jun 2021 11:30:33 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id b11so9872921edy.4 for ; Fri, 18 Jun 2021 11:30:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=G+4b27f3cSkwtnDT4Xx164bd7wjuZ3sF4a5CqFmM2cs=; b=nuA8WJLNcVhq2V3LxAC0TUZfP9TIwXVJKzt1YKB/xktOxsubrnCt5lMnIvU2eTnx58 ZUdLXb8ACXLvKITzao8GXhNNb/WwTsKhaoDO2sbb6Rd8FjTjeNB2xJsxAX+erMLe0AOu 0alzta6zuFREqcO3vwYnAv8siVPBVmEx6L8mwRqueqWoCEJnL58Ly8AmZreaP8Por4cK LerOU3RrzJEGpZZCsoR65NRsS+y/spcaNw8h0HPU/99KE7VSUntEKH349sgTCFhXjIy1 om/XxhnEqNIx5/USeeF/sO05sztZweaSImkSdV+UxlnUpiPBu3QOlyc2crdM9sxNqVLU +fkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=G+4b27f3cSkwtnDT4Xx164bd7wjuZ3sF4a5CqFmM2cs=; b=MHI+UaYRx4JanwlmZEEH4mtxCv5UegAmjBr2Sy6SdsTEF6e5jaHQo6Gvr6oOM4XMiZ 5MuiK0JAb36KZONfeO/gSIQK19la1L8T+6KunLKbhC/ujtmYUKpoOP1cRkQXUUfMK3ec tvHruu2UfrtiySL1xrqP02KbhVyFd8oxwtCHjttWlUnVSqVTZhL9pf2tB7JZad3twKUQ 91jUYjz0Xc5lXJT7y0wni+UImyk51dD5jOGiPX/7Pw4NNTj6qN/xjYZn4wO45KiRDPtD +IDqSa/BpXsND2iw1bvZ9ISQtnRMoH6HBhzyP2gEN+ETvTVj284Cu+WXkXthf2XROHmw GK2g== X-Gm-Message-State: AOAM532+Esr9qwB2t4Q+CRBSdoclnu9X0v15l9sTP65sxlljEBFfWQXM Ge0agr1K0QFiEG/xYja+5LI= X-Google-Smtp-Source: ABdhPJxq35+Am/KfDv+G78KklB5bWFaHe2fHlB38Nx2Ik4soV9YidiH76geaElQERh5ooWsU+wrWGw== X-Received: by 2002:a05:6402:3594:: with SMTP id y20mr7032670edc.299.1624041031954; Fri, 18 Jun 2021 11:30:31 -0700 (PDT) Received: from localhost.localdomain ([188.26.224.68]) by smtp.gmail.com with ESMTPSA id s11sm6071988edd.65.2021.06.18.11.30.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:30:31 -0700 (PDT) From: Vladimir Oltean To: Jakub Kicinski , "David S. Miller" , netdev@vger.kernel.org Cc: Florian Fainelli , Andrew Lunn , Vivien Didelot , Vladimir Oltean Subject: [PATCH net-next 2/6] net: dsa: export the dsa_port_is_{user,cpu,dsa} helpers Date: Fri, 18 Jun 2021 21:30:13 +0300 Message-Id: <20210618183017.3340769-3-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618183017.3340769-1-olteanv@gmail.com> References: <20210618183017.3340769-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Vladimir Oltean The difference between dsa_is_user_port and dsa_port_is_user is that the former needs to look up the list of ports of the DSA switch tree in order to find the struct dsa_port, while the latter directly receives it as an argument. dsa_is_user_port is already in widespread use and has its place, so there isn't any chance of converting all callers to a single form. But being able to do: dsa_port_is_user(dp) instead of dsa_is_user_port(dp->ds, dp->index) is much more efficient too, especially when the "dp" comes from an iterator over the DSA switch tree - this reduces the complexity from quadratic to linear. Move these helpers from dsa2.c to include/net/dsa.h so that others can use them too. Signed-off-by: Vladimir Oltean Reviewed-by: Florian Fainelli Reviewed-by: Andrew Lunn --- include/net/dsa.h | 15 +++++++++++++++ net/dsa/dsa2.c | 15 --------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/net/dsa.h b/include/net/dsa.h index 289d68e82da0..ea47783d5695 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -409,6 +409,21 @@ static inline struct dsa_port *dsa_to_port(struct dsa_switch *ds, int p) return NULL; } +static inline bool dsa_port_is_dsa(struct dsa_port *port) +{ + return port->type == DSA_PORT_TYPE_DSA; +} + +static inline bool dsa_port_is_cpu(struct dsa_port *port) +{ + return port->type == DSA_PORT_TYPE_CPU; +} + +static inline bool dsa_port_is_user(struct dsa_port *dp) +{ + return dp->type == DSA_PORT_TYPE_USER; +} + static inline bool dsa_is_unused_port(struct dsa_switch *ds, int p) { return dsa_to_port(ds, p)->type == DSA_PORT_TYPE_UNUSED; diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index ba244fbd9646..9000a8c84baf 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -219,21 +219,6 @@ static void dsa_tree_put(struct dsa_switch_tree *dst) kref_put(&dst->refcount, dsa_tree_release); } -static bool dsa_port_is_dsa(struct dsa_port *port) -{ - return port->type == DSA_PORT_TYPE_DSA; -} - -static bool dsa_port_is_cpu(struct dsa_port *port) -{ - return port->type == DSA_PORT_TYPE_CPU; -} - -static bool dsa_port_is_user(struct dsa_port *dp) -{ - return dp->type == DSA_PORT_TYPE_USER; -} - static struct dsa_port *dsa_tree_find_port_by_node(struct dsa_switch_tree *dst, struct device_node *dn) { From patchwork Fri Jun 18 18:30:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12332013 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 C1F69C49361 for ; Fri, 18 Jun 2021 18:30:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AB0C4613E2 for ; Fri, 18 Jun 2021 18:30:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235117AbhFRScy (ORCPT ); Fri, 18 Jun 2021 14:32:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234467AbhFRScp (ORCPT ); Fri, 18 Jun 2021 14:32:45 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5440CC061768 for ; Fri, 18 Jun 2021 11:30:34 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id my49so17213689ejc.7 for ; Fri, 18 Jun 2021 11:30:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6mIj7KiO52SrARAQx2Qhs8X77ZprGkslo3wS6baXgus=; b=RBUF7C3Y+t/GNQQgE5cGHj6DXg64WbelSYLtt6WbkwWpVzsqfOV13B/ljnET9ldPBr CdbS9ZfupJBM2vWEOjW8InWK666nWUKK/K6WN38L/gzi0OOWgVggkbZZzxHn72lkCfEO tEBqCLFvn+86V1hPUqIiAkrvmxkQdqCrRT5ChFIkKQqK6urWAkfUtIehzyBArn04bCuP lHU5ckfC46iGB8FtEo/kwwF3PkmjSgxA0OX1q+LDM99k76vTu8H8pbWqB50X7pw0i92Q 3dlgc2c94X2k9xb3PhzVrvFs8P+8KstcRAo2H3oUD0x5NdiV/Bvf9r+cV3wWwzDRXxCb u/Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6mIj7KiO52SrARAQx2Qhs8X77ZprGkslo3wS6baXgus=; b=SYpQE9uVQCNHdygE5Vt6rTZ9rLpH4L6Ka+BF+bP1+GPt7OTVQ1p9YNUVGlrZU8/FIM oxlURulE7QIHFG1i2T7zlNvd/N/t+hjObzEJ38MxjjNw0LIch+ZBWMhKzLIn2/cQ0ikR dBjiJa9dkTkU5CwSnexAnDR8tNPtGPHDCfGPoV6D6sY8njm8ttq+D8+/1+oUN+dE2Z25 tfw5/O+lUa4KikVb0pTmtO3l1s43faUXU263RytalX1yvsh77vD80Q60E0WgxN8SK9I5 x61pGwKSMY341homw7rSRQL+zhfz4CJHXRZV/5oqBQMj00t6z2BYQmzlcsB63YcLhVRs bQrA== X-Gm-Message-State: AOAM530x2QrnBHmiVlD+EIqFqbtGGKjyWeF5YpA7+7r0nADFQqpt7SUP 6QN4uvjRl6+iEQrH1yalLmIAp4OCCZA= X-Google-Smtp-Source: ABdhPJxi1fqy8BiyUKOKEX/DzZc70BtEn1G3bQUnFX2uCSIX4+JHbRD51YLbY1uPOH0Vm0yGjPKO1Q== X-Received: by 2002:a17:906:19cc:: with SMTP id h12mr12208563ejd.306.1624041032951; Fri, 18 Jun 2021 11:30:32 -0700 (PDT) Received: from localhost.localdomain ([188.26.224.68]) by smtp.gmail.com with ESMTPSA id s11sm6071988edd.65.2021.06.18.11.30.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:30:32 -0700 (PDT) From: Vladimir Oltean To: Jakub Kicinski , "David S. Miller" , netdev@vger.kernel.org Cc: Florian Fainelli , Andrew Lunn , Vivien Didelot , Vladimir Oltean Subject: [PATCH net-next 3/6] net: dsa: execute dsa_switch_mdb_add only for routing port in cross-chip topologies Date: Fri, 18 Jun 2021 21:30:14 +0300 Message-Id: <20210618183017.3340769-4-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618183017.3340769-1-olteanv@gmail.com> References: <20210618183017.3340769-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Vladimir Oltean Currently, the notifier for adding a multicast MAC address matches on the targeted port and on all DSA links in the system, be they upstream or downstream links. This leads to a considerable amount of useless traffic. Consider this daisy chain topology, and a MDB add notifier emitted on sw0p0. It matches on sw0p0, sw0p3, sw1p3 and sw2p4. sw0p0 sw0p1 sw0p2 sw0p3 sw0p4 [ user ] [ user ] [ user ] [ dsa ] [ cpu ] [ x ] [ ] [ ] [ x ] [ ] | +---------+ | sw1p0 sw1p1 sw1p2 sw1p3 sw1p4 [ user ] [ user ] [ user ] [ dsa ] [ dsa ] [ ] [ ] [ ] [ x ] [ x ] | +---------+ | sw2p0 sw2p1 sw2p2 sw2p3 sw2p4 [ user ] [ user ] [ user ] [ user ] [ dsa ] [ ] [ ] [ ] [ ] [ x ] But switch 0 has no reason to send the multicast traffic for that MAC address on sw0p3, which is how it reaches switches 1 and 2. Those switches don't expect, according to the user configuration, to receive this multicast address from switch 1, and they will drop it anyway, because the only valid destination is the port they received it on. They only need to configure themselves to deliver that multicast address _towards_ switch 1, where the MDB entry is installed. Similarly, switch 1 should not send this multicast traffic towards sw1p3, because that is how it reaches switch 2. With this change, the heat map for this MDB notifier changes as follows: sw0p0 sw0p1 sw0p2 sw0p3 sw0p4 [ user ] [ user ] [ user ] [ dsa ] [ cpu ] [ x ] [ ] [ ] [ ] [ ] | +---------+ | sw1p0 sw1p1 sw1p2 sw1p3 sw1p4 [ user ] [ user ] [ user ] [ dsa ] [ dsa ] [ ] [ ] [ ] [ ] [ x ] | +---------+ | sw2p0 sw2p1 sw2p2 sw2p3 sw2p4 [ user ] [ user ] [ user ] [ user ] [ dsa ] [ ] [ ] [ ] [ ] [ x ] Now the mdb notifier behaves the same as the fdb notifier. Signed-off-by: Vladimir Oltean Reviewed-by: Florian Fainelli --- net/dsa/switch.c | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/net/dsa/switch.c b/net/dsa/switch.c index 9bf8e20ecdf3..8b601ced6b45 100644 --- a/net/dsa/switch.c +++ b/net/dsa/switch.c @@ -232,36 +232,15 @@ static int dsa_switch_lag_leave(struct dsa_switch *ds, return 0; } -static bool dsa_switch_mdb_match(struct dsa_switch *ds, int port, - struct dsa_notifier_mdb_info *info) -{ - if (ds->index == info->sw_index && port == info->port) - return true; - - if (dsa_is_dsa_port(ds, port)) - return true; - - return false; -} - static int dsa_switch_mdb_add(struct dsa_switch *ds, struct dsa_notifier_mdb_info *info) { - int err = 0; - int port; + int port = dsa_towards_port(ds, info->sw_index, info->port); if (!ds->ops->port_mdb_add) return -EOPNOTSUPP; - for (port = 0; port < ds->num_ports; port++) { - if (dsa_switch_mdb_match(ds, port, info)) { - err = ds->ops->port_mdb_add(ds, port, info->mdb); - if (err) - break; - } - } - - return err; + return ds->ops->port_mdb_add(ds, port, info->mdb); } static int dsa_switch_mdb_del(struct dsa_switch *ds, From patchwork Fri Jun 18 18:30:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12332015 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 3B805C48BDF for ; Fri, 18 Jun 2021 18:30:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1996960E09 for ; Fri, 18 Jun 2021 18:30:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235091AbhFRScz (ORCPT ); Fri, 18 Jun 2021 14:32:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234474AbhFRScq (ORCPT ); Fri, 18 Jun 2021 14:32:46 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D26EC0617A6 for ; Fri, 18 Jun 2021 11:30:35 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id s15so9831183edt.13 for ; Fri, 18 Jun 2021 11:30:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bxCxdl7smdQEJi6TjESjk98pk/y1jol/SJVHGSD71tc=; b=KnRXkRcJ0HgUM/eqxNfc9XFczN8tNYZhxP8bCq1dipg+6PAl0OIArabqfwBtAMqNFC 45Ge2H6L/tbNe/qI5wx56lzwpTe6NwZWaDDQf6gQW3ii+qHLrQBIdkzQCQ/4ItJFT9e8 zWgIyB9Zeu8COAXJPWRbmay6IYxpJVejOR69tK84ToB7CmiB03LEZdgVBcXB7XWj2S7x SV6je155QwdHaWaCroIhOlcyG/P3uVisRjir0QbrXOBaAuFYXlzc1TYBcRxFvWSuS1a3 yi8432yYA8uyBDFgms7yUOV50LmmXBTwySPTKNBY2jhGESqfw90eWNZg/2lUtTWixU6C /9DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bxCxdl7smdQEJi6TjESjk98pk/y1jol/SJVHGSD71tc=; b=V6QLnuTy4DCUvVcCLRlLoxyknibBk2sReBBDTpFTf8w5DlF3Rq4mCLz5yFvYCfig97 qkDeVQwNsFl+dgPKjI8H3Lis3Cqx3Nw8oz/6WBKFraplKBSC64UD0CbJP0aHg/Ua2/Sr B1KeZyy8rYpZPiDdOCAh11LFs6K7enXmJseeo3xdMkE0zMGsoYwloo7u6O+fl4NUGx8u fg+jU1YPkUzNYKil7aocP6APrnfNlgS9zZz/E+rgYkOXR2AtH5XfTFQas3EoTC1hm2HR lmOJzWhIGXiKItGUiFuM2f12x3CPw+B5aPFfsMThNucZYhgTMY9NTGLnz0E507vBcmXa FutA== X-Gm-Message-State: AOAM532NtUxWsjVnsiUvFUN0D8ife6v37VK2YQd2OXlUhs+Ly4v/b7eu vofpxhK19CWsDi84ThQMTWo= X-Google-Smtp-Source: ABdhPJz1vwiul8f4ywvp7KV6+iCn46A9kzJJDy0X+/lGF8jViySe8pQj51hCWoOmdl4Bq+9VVxy6ag== X-Received: by 2002:a05:6402:d06:: with SMTP id eb6mr6784441edb.337.1624041033963; Fri, 18 Jun 2021 11:30:33 -0700 (PDT) Received: from localhost.localdomain ([188.26.224.68]) by smtp.gmail.com with ESMTPSA id s11sm6071988edd.65.2021.06.18.11.30.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:30:33 -0700 (PDT) From: Vladimir Oltean To: Jakub Kicinski , "David S. Miller" , netdev@vger.kernel.org Cc: Florian Fainelli , Andrew Lunn , Vivien Didelot , Vladimir Oltean Subject: [PATCH net-next 4/6] net: dsa: calculate the largest_mtu across all ports in the tree Date: Fri, 18 Jun 2021 21:30:15 +0300 Message-Id: <20210618183017.3340769-5-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618183017.3340769-1-olteanv@gmail.com> References: <20210618183017.3340769-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Vladimir Oltean If we have a cross-chip topology like this: sw0p0 sw0p1 sw0p2 sw0p3 sw0p4 [ cpu ] [ user ] [ user ] [ dsa ] [ user ] | +---------+ | sw1p0 sw1p1 sw1p2 sw1p3 sw1p4 [ user ] [ user ] [ user ] [ dsa ] [ dsa ] and we issue the following commands: 1. ip link set sw0p1 mtu 1700 2. ip link set sw1p1 mtu 1600 we notice the following happening: Command 1. emits a non-targeted MTU notifier for the CPU port (sw0p0) with the largest_mtu calculated across switch 0, of 1700. This matches sw0p0, sw0p3 and sw1p4 (all CPU ports and DSA links). Then, it emits a targeted MTU notifier for the user port (sw0p1), again with MTU 1700 (this doesn't matter). Command 2. emits a non-targeted MTU notifier for the CPU port (sw0p0) with the largest_mtu calculated across switch 1, of 1600. This matches the same group of ports as above, and decreases the MTU for the CPU port and the DSA links from 1700 to 1600. As a result, the sw0p1 user port can no longer communicate with its CPU port at MTU 1700. To address this, we should calculate the largest_mtu across all switches that may share a CPU port, and only emit MTU notifiers with that value. Signed-off-by: Vladimir Oltean Reviewed-by: Florian Fainelli --- net/dsa/slave.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 798944aa847a..ac2ca5f75af3 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -1528,6 +1528,7 @@ int dsa_slave_change_mtu(struct net_device *dev, int new_mtu) struct dsa_port *dp = dsa_slave_to_port(dev); struct dsa_slave_priv *p = netdev_priv(dev); struct dsa_switch *ds = p->dp->ds; + struct dsa_port *dp_iter; struct dsa_port *cpu_dp; int port = p->dp->index; int largest_mtu = 0; @@ -1535,31 +1536,31 @@ int dsa_slave_change_mtu(struct net_device *dev, int new_mtu) int old_master_mtu; int mtu_limit; int cpu_mtu; - int err, i; + int err; if (!ds->ops->port_change_mtu) return -EOPNOTSUPP; - for (i = 0; i < ds->num_ports; i++) { + list_for_each_entry(dp_iter, &ds->dst->ports, list) { int slave_mtu; - if (!dsa_is_user_port(ds, i)) + if (!dsa_port_is_user(dp_iter)) continue; /* During probe, this function will be called for each slave * device, while not all of them have been allocated. That's * ok, it doesn't change what the maximum is, so ignore it. */ - if (!dsa_to_port(ds, i)->slave) + if (!dp_iter->slave) continue; /* Pretend that we already applied the setting, which we * actually haven't (still haven't done all integrity checks) */ - if (i == port) + if (dp_iter == dp) slave_mtu = new_mtu; else - slave_mtu = dsa_to_port(ds, i)->slave->mtu; + slave_mtu = dp_iter->slave->mtu; if (largest_mtu < slave_mtu) largest_mtu = slave_mtu; From patchwork Fri Jun 18 18:30:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12332017 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 DBA80C48BDF for ; Fri, 18 Jun 2021 18:30:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C5E66613ED for ; Fri, 18 Jun 2021 18:30:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235189AbhFRSc4 (ORCPT ); Fri, 18 Jun 2021 14:32:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234865AbhFRScq (ORCPT ); Fri, 18 Jun 2021 14:32:46 -0400 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D4AAC0617A8 for ; Fri, 18 Jun 2021 11:30:37 -0700 (PDT) Received: by mail-ed1-x536.google.com with SMTP id u24so9796046edy.11 for ; Fri, 18 Jun 2021 11:30:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7OCEoq1hjGxlJE++ChuaWucYdz2CNykMHpgEYv142dg=; b=KSbuZsd8AXX+KAQQJdd5xwvKPSPdQ0RQF8gAi8SmvyVlhpt0INmMWJ7lKyRhbuadSg ZUYKjcQ99eLnJ8kBjvyqI5b3qotTulDGHD5kUgQRSxd9y3W9uAKtcJ+yQ+NLEGyOun0I abgw9pVitpPnpng3DZ5jeGSEGMX57ZQVWeSJeF4yBZQJLkeii1eETqILnErO6uk+9jEE Y56TjtQbl4NVL7H9jhZPjSGQdhggUOKCm0+SpAxKjHgjTXPzhkpKXlPf/9cFuAJRqZ0+ G8yGSnNkJhKOV2n7QryTxRcCXkJeWJJOu4Vw6D7JWKOvd5QEYq4jX8gqcuH8ncYbTGvu Eieg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7OCEoq1hjGxlJE++ChuaWucYdz2CNykMHpgEYv142dg=; b=eQwL8CzgHVlYYGuVh5p25g8HeT39Oix44YEwbrAfpRgphGtaGlqSAHitZ+TrkktxLT yQzavKDl6D9a70q2f2PFG9CshgHgyq8OXT6AI4WIm4Z76kkEIzvjiKupIx/s3EuJN+4B cVu2J4t06IG9IyhnIce55Gjmw0KsVI7AlG4v2hj4vTtObaY2yNdmBEJlSGsL6XRNaVkh TsAqXR79iRmq3uvMyEiFMH/gBB4dYODs1Wx9mmmcfYcLgoYq3pqmC2KG7C89T6JM99Pf RY4gMBp+WwQc5cnzyFzfzQlBHnGTKiJUulkb7pHdeNFvyr9naFoCOh0j5QrkX46+Tphz 7LbQ== X-Gm-Message-State: AOAM533hBvH/KSWIS2XvH5vFBB1hdUAxZmkHIviA5bloRv3e9c3rBA1T 3JtgEuHYbxI0Agw111wSz1U= X-Google-Smtp-Source: ABdhPJy9GtUl11A96o8ynfC/AdnDhfyL9w5CsRlCgsao0K+OGawXe9E7I2zclovUI3+fyhIsh9VnVw== X-Received: by 2002:a05:6402:10cc:: with SMTP id p12mr6980092edu.328.1624041035645; Fri, 18 Jun 2021 11:30:35 -0700 (PDT) Received: from localhost.localdomain ([188.26.224.68]) by smtp.gmail.com with ESMTPSA id s11sm6071988edd.65.2021.06.18.11.30.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:30:34 -0700 (PDT) From: Vladimir Oltean To: Jakub Kicinski , "David S. Miller" , netdev@vger.kernel.org Cc: Florian Fainelli , Andrew Lunn , Vivien Didelot , Vladimir Oltean Subject: [PATCH net-next 5/6] net: dsa: targeted MTU notifiers should only match on one port Date: Fri, 18 Jun 2021 21:30:16 +0300 Message-Id: <20210618183017.3340769-6-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618183017.3340769-1-olteanv@gmail.com> References: <20210618183017.3340769-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Vladimir Oltean dsa_slave_change_mtu() calls dsa_port_mtu_change() twice: - it sends a cross-chip notifier with the MTU of the CPU port which is used to update the DSA links. - it sends one targeted MTU notifier which is supposed to only match the user port on which we are changing the MTU. The "propagate_upstream" variable is used here to bypass the cross-chip notifier system from switch.c But due to a mistake, the second, targeted notifier matches not only on the user port, but also on the DSA link which is a member of the same switch, if that exists. And because the DSA links of the entire dst were programmed in a previous round to the largest_mtu via a "propagate_upstream == true" notification, then the dsa_port_mtu_change(propagate_upstream == false) call that is immediately upcoming will break the MTU on the one DSA link which is chip-wise local to the dp whose MTU is changing right now. Example given this daisy chain topology: sw0p0 sw0p1 sw0p2 sw0p3 sw0p4 [ cpu ] [ user ] [ user ] [ dsa ] [ user ] [ x ] [ ] [ ] [ x ] [ ] | +---------+ | sw1p0 sw1p1 sw1p2 sw1p3 sw1p4 [ user ] [ user ] [ user ] [ dsa ] [ dsa ] [ ] [ ] [ ] [ ] [ x ] ip link set sw0p1 mtu 9000 ip link set sw1p1 mtu 9000 # at this stage, sw0p1 and sw1p1 can talk # to one another using jumbo frames ip link set sw0p2 mtu 1500 # this programs the sw0p3 DSA link first to # the largest_mtu of 9000, then reprograms it to # 1500 with the "propagate_upstream == false" # notifier, breaking communication between # sw0p1 and sw1p1 To escape from this situation, make the targeted match really match on a single port - the user port, and rename the "propagate_upstream" variable to "targeted_match" to clarify the intention and avoid future issues. Signed-off-by: Vladimir Oltean Reviewed-by: Florian Fainelli --- net/dsa/dsa_priv.h | 4 ++-- net/dsa/port.c | 4 ++-- net/dsa/slave.c | 9 +++++---- net/dsa/switch.c | 9 ++++++--- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h index b8b17474b72b..b0811253d101 100644 --- a/net/dsa/dsa_priv.h +++ b/net/dsa/dsa_priv.h @@ -84,7 +84,7 @@ struct dsa_notifier_vlan_info { /* DSA_NOTIFIER_MTU */ struct dsa_notifier_mtu_info { - bool propagate_upstream; + bool targeted_match; int sw_index; int port; int mtu; @@ -200,7 +200,7 @@ int dsa_port_vlan_filtering(struct dsa_port *dp, bool vlan_filtering, bool dsa_port_skip_vlan_configuration(struct dsa_port *dp); int dsa_port_ageing_time(struct dsa_port *dp, clock_t ageing_clock); int dsa_port_mtu_change(struct dsa_port *dp, int new_mtu, - bool propagate_upstream); + bool targeted_match); int dsa_port_fdb_add(struct dsa_port *dp, const unsigned char *addr, u16 vid); int dsa_port_fdb_del(struct dsa_port *dp, const unsigned char *addr, diff --git a/net/dsa/port.c b/net/dsa/port.c index 6379d66a6bb3..5c93f1e1a03d 100644 --- a/net/dsa/port.c +++ b/net/dsa/port.c @@ -567,11 +567,11 @@ int dsa_port_mrouter(struct dsa_port *dp, bool mrouter, } int dsa_port_mtu_change(struct dsa_port *dp, int new_mtu, - bool propagate_upstream) + bool targeted_match) { struct dsa_notifier_mtu_info info = { .sw_index = dp->ds->index, - .propagate_upstream = propagate_upstream, + .targeted_match = targeted_match, .port = dp->index, .mtu = new_mtu, }; diff --git a/net/dsa/slave.c b/net/dsa/slave.c index ac2ca5f75af3..5e668e529575 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -1586,14 +1586,15 @@ int dsa_slave_change_mtu(struct net_device *dev, int new_mtu) goto out_master_failed; /* We only need to propagate the MTU of the CPU port to - * upstream switches. + * upstream switches, so create a non-targeted notifier which + * updates all switches. */ - err = dsa_port_mtu_change(cpu_dp, cpu_mtu, true); + err = dsa_port_mtu_change(cpu_dp, cpu_mtu, false); if (err) goto out_cpu_failed; } - err = dsa_port_mtu_change(dp, new_mtu, false); + err = dsa_port_mtu_change(dp, new_mtu, true); if (err) goto out_port_failed; @@ -1607,7 +1608,7 @@ int dsa_slave_change_mtu(struct net_device *dev, int new_mtu) if (new_master_mtu != old_master_mtu) dsa_port_mtu_change(cpu_dp, old_master_mtu - dsa_tag_protocol_overhead(cpu_dp->tag_ops), - true); + false); out_cpu_failed: if (new_master_mtu != old_master_mtu) dev_set_mtu(master, old_master_mtu); diff --git a/net/dsa/switch.c b/net/dsa/switch.c index 8b601ced6b45..75f567390a6b 100644 --- a/net/dsa/switch.c +++ b/net/dsa/switch.c @@ -52,10 +52,13 @@ static int dsa_switch_ageing_time(struct dsa_switch *ds, static bool dsa_switch_mtu_match(struct dsa_switch *ds, int port, struct dsa_notifier_mtu_info *info) { - if (ds->index == info->sw_index) - return (port == info->port) || dsa_is_dsa_port(ds, port); + if (ds->index == info->sw_index && port == info->port) + return true; - if (!info->propagate_upstream) + /* Do not propagate to other switches in the tree if the notifier was + * targeted for a single switch. + */ + if (info->targeted_match) return false; if (dsa_is_dsa_port(ds, port) || dsa_is_cpu_port(ds, port)) From patchwork Fri Jun 18 18:30:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12332019 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 2C21CC48BE8 for ; Fri, 18 Jun 2021 18:30:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 17166613EE for ; Fri, 18 Jun 2021 18:30:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235236AbhFRSdB (ORCPT ); Fri, 18 Jun 2021 14:33:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233791AbhFRScs (ORCPT ); Fri, 18 Jun 2021 14:32:48 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 291E4C061574 for ; Fri, 18 Jun 2021 11:30:38 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id ho18so17247258ejc.8 for ; Fri, 18 Jun 2021 11:30:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oDUgR9pnsaWBDFSwkrbZ0JZ9Qg981RAkrXovwQDOhgQ=; b=pxbY3LYWKE/yaOMQj2SXrlTCm7Ksg/sctj0LRwj+LV557IddBJeCNrl+4PJAju3F+r cxZYoKfHQ1evQrCfJcIMWq/tYdjDypFmwYL2nlBu6o0lS7/oWVd4KvJ349iZbJX0ncOu AkmvcdHyhEaxEPNcxd4z3+Z9XB2gWW3L2UyQyFTUj2z66aewbLphYKb0i4DLy9OkHBRC 969NTYqjGFkjd11EW7MM2L07AjNjPk90hPZWSlCnThOj0wzai9O8yYbOU2KfV4Xn+nrP oCoojP5Ei8zNLikqBLXhGSYSo0nK4zVsmp1ch6LSbBZjKNDsfLH9hej2F0mST6OFnDxJ lLzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oDUgR9pnsaWBDFSwkrbZ0JZ9Qg981RAkrXovwQDOhgQ=; b=SrQuCOyWMSNESNoz8s70MbWxJTC3JAZxxJ2ZOJHLJj8wGLKegCfLJsswRTK5276JQp 7i9c79dfqdh1gD4SVJNSbaEG/W+skWy1JTJM2Gcl45s0lyX/Tk8Lm9mXxfQEQ1ToDbue EDc5qSM9+I09Mcqr2X2zWX3ATI13pUqBy65QbuWg+d9gB17BCYoSefofB/5p16NaA2If 4frdjVNKym3REPK0FqEzIzoKq+Vxfh2yNC87245h38E8bIHCqB+3mPPcjKtWOgMkctw1 WJ9qUUsJcUiwMSj6vi1V29kKR62uwSvP02LEJDDzZWK8INlZAqLf5hg0fxpL787E+yy1 z3vg== X-Gm-Message-State: AOAM532RgpuJpYvXTVpZ51HYlhxaJ0wcReKdofntKfuEjIUnyjZfv42S OxtRpy+eJB/YqKQv5jRK8go= X-Google-Smtp-Source: ABdhPJz53sSkq0aq9h74vaoz7IZpjDq/JYeZNoWAnpUM9XJ7+6Kzn0ONEbhvKCdeFxgAWQPpoYNKFA== X-Received: by 2002:a17:906:dffc:: with SMTP id lc28mr12134785ejc.96.1624041036759; Fri, 18 Jun 2021 11:30:36 -0700 (PDT) Received: from localhost.localdomain ([188.26.224.68]) by smtp.gmail.com with ESMTPSA id s11sm6071988edd.65.2021.06.18.11.30.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 11:30:36 -0700 (PDT) From: Vladimir Oltean To: Jakub Kicinski , "David S. Miller" , netdev@vger.kernel.org Cc: Florian Fainelli , Andrew Lunn , Vivien Didelot , Vladimir Oltean , Horatiu Vultur Subject: [PATCH net-next 6/6] net: dsa: remove cross-chip support from the MRP notifiers Date: Fri, 18 Jun 2021 21:30:17 +0300 Message-Id: <20210618183017.3340769-7-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210618183017.3340769-1-olteanv@gmail.com> References: <20210618183017.3340769-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Vladimir Oltean With MRP hardware assist being supported only by the ocelot switch family, which by design does not support cross-chip bridging, the current match functions are at best a guess and have not been confirmed in any way to do anything relevant in a multi-switch topology. Drop the code and make the notifiers match only on the targeted switch port. Cc: Horatiu Vultur Signed-off-by: Vladimir Oltean Reviewed-by: Florian Fainelli --- net/dsa/switch.c | 53 +++++++----------------------------------------- 1 file changed, 7 insertions(+), 46 deletions(-) diff --git a/net/dsa/switch.c b/net/dsa/switch.c index 75f567390a6b..7e948bf15fe0 100644 --- a/net/dsa/switch.c +++ b/net/dsa/switch.c @@ -346,36 +346,16 @@ static int dsa_switch_change_tag_proto(struct dsa_switch *ds, return 0; } -static bool dsa_switch_mrp_match(struct dsa_switch *ds, int port, - struct dsa_notifier_mrp_info *info) -{ - if (ds->index == info->sw_index && port == info->port) - return true; - - if (dsa_is_dsa_port(ds, port)) - return true; - - return false; -} - static int dsa_switch_mrp_add(struct dsa_switch *ds, struct dsa_notifier_mrp_info *info) { - int err = 0; - int port; - if (!ds->ops->port_mrp_add) return -EOPNOTSUPP; - for (port = 0; port < ds->num_ports; port++) { - if (dsa_switch_mrp_match(ds, port, info)) { - err = ds->ops->port_mrp_add(ds, port, info->mrp); - if (err) - break; - } - } + if (ds->index == info->sw_index) + return ds->ops->port_mrp_add(ds, info->port, info->mrp); - return err; + return 0; } static int dsa_switch_mrp_del(struct dsa_switch *ds, @@ -390,39 +370,20 @@ static int dsa_switch_mrp_del(struct dsa_switch *ds, return 0; } -static bool -dsa_switch_mrp_ring_role_match(struct dsa_switch *ds, int port, - struct dsa_notifier_mrp_ring_role_info *info) -{ - if (ds->index == info->sw_index && port == info->port) - return true; - - if (dsa_is_dsa_port(ds, port)) - return true; - - return false; -} - static int dsa_switch_mrp_add_ring_role(struct dsa_switch *ds, struct dsa_notifier_mrp_ring_role_info *info) { int err = 0; - int port; if (!ds->ops->port_mrp_add) return -EOPNOTSUPP; - for (port = 0; port < ds->num_ports; port++) { - if (dsa_switch_mrp_ring_role_match(ds, port, info)) { - err = ds->ops->port_mrp_add_ring_role(ds, port, - info->mrp); - if (err) - break; - } - } + if (ds->index == info->sw_index) + return ds->ops->port_mrp_add_ring_role(ds, info->port, + info->mrp); - return err; + return 0; } static int