From patchwork Mon Jun 21 16:42: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: 464884 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, 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 4EFF7C48BC2 for ; Mon, 21 Jun 2021 17:03:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 36F996102A for ; Mon, 21 Jun 2021 17:03:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230326AbhFURFT (ORCPT ); Mon, 21 Jun 2021 13:05:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230500AbhFURFM (ORCPT ); Mon, 21 Jun 2021 13:05:12 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 382EDC051C75 for ; Mon, 21 Jun 2021 09:42:36 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id nb6so29769927ejc.10 for ; Mon, 21 Jun 2021 09:42: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=Ar8srF6RoxucIg9He9/E36VcEjkgKbzFguO1R6WKeOo=; b=peayvWjX4KWkJJxfAVXYdYknyjVdiB+aAJVSzovUVgNKUD7Lb7uGH/30RDLT4vnK55 9lBdHx74MXPQSgIWwmPDRZQgnDVHcJNwn96UMRDrc6fDQJHhvAu2o7kGnXg+S786SxSX 0UqhT22eOzLtZOslLS198z/p+UA0MhCPj2/VlX1naA0DVKdEq85uKDdzG2Y3X66nMkuE 23jSoTqJOzw1fQZRhaxmpcKER4KdofPTa0S/E+ocNJrVUYPClQVfTtX7b4YRAstFUij+ PS5XcBueDuuTPJ62KW2Vjuq6bu2h7CwKUJ4q3ZQ7d78BVGnJN3cWTND2YamwIX6eMUAE S7aw== 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=Ar8srF6RoxucIg9He9/E36VcEjkgKbzFguO1R6WKeOo=; b=GZFqTF+LJdILM3T6/DhkRQxvr0+9PtVEwjBTSJ1jNwIae+ck+5DF00GJ4fy+7+oCsH ZP9AWBrRyavAWejr6LL0i6r23Ci4e3PeDUyXIkJWqidYxd9CqGF54jL9OBY+VZ0+hJBA U+SbkDvMDsF3/wvrbdYDjeLtavV2xNEB77aB8hERzmb7gqtWijIpayPuyZHOXYOF1wKF rKV+jRV8q2QD6RpBrDopJHX53GW38FGEYfnDBORTuveqznlOY5op4Ib0fUzAZEB8g09M K6XJFuuEsg+XZpuPgemH3p+gEYo24MOJgZsQB1zzRUC85wa6fmBaDXUtlx3Kec2kIxn5 4bDw== X-Gm-Message-State: AOAM53169kmMWWS5z1/zGCMadtto6ZgNEQMeHgbnwS/o7o4m2ZzM5Wno QWEN3kw2yz5940T/e83BmhA= X-Google-Smtp-Source: ABdhPJw989ZN4qylLpu1dIrX77rgqCvroIEJvXRwXE2qfw0wkC5LJKn99+XpViL34YCTy2LoC9A1+g== X-Received: by 2002:a17:906:2b01:: with SMTP id a1mr12574813ejg.133.1624293754843; Mon, 21 Jun 2021 09:42:34 -0700 (PDT) Received: from localhost.localdomain ([188.26.224.68]) by smtp.gmail.com with ESMTPSA id c23sm10931093eds.57.2021.06.21.09.42.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 09:42: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 v2 net-next 1/6] net: dsa: assert uniqueness of dsa, member properties Date: Mon, 21 Jun 2021 19:42:14 +0300 Message-Id: <20210621164219.3780244-2-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621164219.3780244-1-olteanv@gmail.com> References: <20210621164219.3780244-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.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 --- v1->v2: none 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 Mon Jun 21 16:42: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: 464883 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, 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 DB5F9C4743C for ; Mon, 21 Jun 2021 17:03:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C43D06102A for ; Mon, 21 Jun 2021 17:03:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231179AbhFURF2 (ORCPT ); Mon, 21 Jun 2021 13:05:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230061AbhFURFN (ORCPT ); Mon, 21 Jun 2021 13:05:13 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E612C051C76 for ; Mon, 21 Jun 2021 09:42:37 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id h17so9941893edw.11 for ; Mon, 21 Jun 2021 09:42: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=fSu4Q0hGuy8oluj1nx2hUlLrrsyIEnesNjOpjwQ6bsg=; b=rWToYzUgc/xVMHcT+XyYdEa2UB1YiouKUcE7ZTpXxT9jkFQ0QESw/ep/j/zP5bgniB MXiBmOXaifm+tFul6aQQSo53WRXg/goPtq4EADU6Rlf98fD2P/iQMum1GZhQD0hCv+Na Ad2KDb5w03L/u7AriFoZOcvBt6vLuq9Io+8ni7ZemDPsWt7eD+OPKPPCOXJrEiYsylLz xdSdcMtmZVKe22D97RdNzb3eXwK/x3fSHPl60MHHIpPA65t6IrKifz2L+ILVbwhWWiP5 Nc0PoL4ST+nYz4XEb2jbOxHSpIIq0oYSHEk2Dn+FrBL3N20RuAw1J46NNe1RDDBQtFHt Ehig== 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=fSu4Q0hGuy8oluj1nx2hUlLrrsyIEnesNjOpjwQ6bsg=; b=WAplwkvOr9HERV/wNN44hLOhdJmQ5PhQcJO2T/3YdToZtt0tW8S0eUd/S8Tq//uCG3 9xPwoNLhZYVlECuBMaPi7WC1tCh92ULn/wHkW3egtZR8it4h0LGx/JIHy/ZGLAuTVBZP 5ZHVKqmv8ze/o3c0HCYxwTDACDeL0V5o2AAkK3S2Y8gAZslfk6lZBmKifzoFcc7KH/9x ykk5YX849It467zYqG7YX0PMjCE2LSY94/lYSWLTF9NVRhav4Hd1tnSujv8DooK5CXGs B+BSTRMXkntqalxPdz/4H5JZV2uN8uO7nQsIIJmC9g+1MAzFmy8V55rd6UTrr9nX5Fo0 8FSg== X-Gm-Message-State: AOAM5301KxA5I3ZSoUNNBhChOpkT9tTvsWPi7DFxbq//jqomeKa83Kap +gep02tPmGsPd9W8ynLwVm8= X-Google-Smtp-Source: ABdhPJxzC1qpxfSulSDBuFoRHBais+/MEIvvrJtDuGZ/Elm/gYH1tMYcx94q3yMWXYPpOuv5fqpzVg== X-Received: by 2002:a50:aa87:: with SMTP id q7mr14238610edc.97.1624293755613; Mon, 21 Jun 2021 09:42:35 -0700 (PDT) Received: from localhost.localdomain ([188.26.224.68]) by smtp.gmail.com with ESMTPSA id c23sm10931093eds.57.2021.06.21.09.42.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 09:42:35 -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 v2 net-next 2/6] net: dsa: export the dsa_port_is_{user, cpu, dsa} helpers Date: Mon, 21 Jun 2021 19:42:15 +0300 Message-Id: <20210621164219.3780244-3-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621164219.3780244-1-olteanv@gmail.com> References: <20210621164219.3780244-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.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 --- v1->v2: none 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 Mon Jun 21 16:42: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: 465620 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, 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 6CF16C4743C for ; Mon, 21 Jun 2021 17:03:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5612860C3F for ; Mon, 21 Jun 2021 17:03:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230452AbhFURFV (ORCPT ); Mon, 21 Jun 2021 13:05:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230056AbhFURFN (ORCPT ); Mon, 21 Jun 2021 13:05:13 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E72DC051C77 for ; Mon, 21 Jun 2021 09:42:37 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id my49so29786577ejc.7 for ; Mon, 21 Jun 2021 09:42:37 -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=fubqmhqBlcfQuk4CIMHD6bgtFWujos5iEFVkXjRunw4=; b=tCxRYx3bPk3m5MMir+pvNeLqKqr/dM4oQJnSM/xcCcCk/Al9/16xv+WzjELOv1o+NE nOP22r/ZB/e7rkcx3jlW/hj31dwbA8keOcNyzBDPFCLE9lusCsYvo/ZYPatjHiPzK6XS XO4FbT188taurp49AOXGRZQN9AidnRIVKnV/07yPFi7XktQx7iSwjs7sHugQEDaEAuVw 0O52me2O4bu7OPZClja0HAdk3Bg6AVCXtBo84ROk19rTCZdabwmSka6gn5VcyKKqC1g7 F1zoWOKZiQ9kMOwOj6aJuFqUTvbqFTtcR5zRDtcCsQMxlzmiNYaCRUYPiNuw1MsVk7x7 pTZg== 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=fubqmhqBlcfQuk4CIMHD6bgtFWujos5iEFVkXjRunw4=; b=PsrcdQbpjZbWDTomQHO5P/p9d3bOr7EwC01HFhsAun3KZTk3eqo7bpTS7/m5WTIZr2 zB4H/RG+S1UpcZur8tODgAJ6aZc8NQ953VrsNl/QEeomn++Cym4uy1qu8iI9wpXpH3rZ MpQJCT7+otEoQdb+nzjcmQTRXJchXKScQQdmN+t0AJrA3mJriP5LhI2aQIxPplZKFa96 5gTK4u2tax56+UwgVGW/YCP3b5dbv5Er4m9VGh84z9Xvp4Rf+to1kWeQi5B2MKIxOid5 ToqxN6iciDvVWY2ZPwHkCcgAVBaoBlje4VbeHwz/h2FY99c6Kj34oKuFnmQ+620LsGeE U1rQ== X-Gm-Message-State: AOAM533WOJbIkVGZthyMzU4iUWxmb57ZTJD/WELfUcFZov+mlCp78tcn D4mVfD9vsCsNNAWlov9atwU= X-Google-Smtp-Source: ABdhPJzTiqHbHYdFiFbc7d6UYZgrSUorYFSbU8Pj1Mck7hpxywvMvH/qa4FR64F4wnzpLDUA/AMTNQ== X-Received: by 2002:a17:906:69cc:: with SMTP id g12mr18368046ejs.550.1624293756467; Mon, 21 Jun 2021 09:42:36 -0700 (PDT) Received: from localhost.localdomain ([188.26.224.68]) by smtp.gmail.com with ESMTPSA id c23sm10931093eds.57.2021.06.21.09.42.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 09:42: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 Subject: [PATCH v2 net-next 3/6] net: dsa: execute dsa_switch_mdb_add only for routing port in cross-chip topologies Date: Mon, 21 Jun 2021 19:42:16 +0300 Message-Id: <20210621164219.3780244-4-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621164219.3780244-1-olteanv@gmail.com> References: <20210621164219.3780244-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.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 --- v1->v2: none 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 Mon Jun 21 16:42: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: 464882 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, 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 79D54C48BC2 for ; Mon, 21 Jun 2021 17:03:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5F64560C3F for ; Mon, 21 Jun 2021 17:03:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231442AbhFURFh (ORCPT ); Mon, 21 Jun 2021 13:05:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230071AbhFURFO (ORCPT ); Mon, 21 Jun 2021 13:05:14 -0400 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC717C051C78 for ; Mon, 21 Jun 2021 09:42:38 -0700 (PDT) Received: by mail-ed1-x530.google.com with SMTP id d7so19938328edx.0 for ; Mon, 21 Jun 2021 09:42: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=KORWMhnUBbgHwjYhqK1PttxgJfNlQ4Zi3Dop8SsLEok=; b=JpSnamxlUe74w0XaPRHl0nMiXA5G+f1D7m3w09bW3Ifc/0WV0S161D1clFTXDR4I6X JvUr0v/ynd1IyQgZFUuLCspnfyvQ8uidkKRMLLhFMYJXQE30N/51/bOAHohQF2OUN2KM onHQSiwOjCCmd/N0tD2Lu9+o+FA5DL4FL/p3GStGP4nHbfNZc95WTcYxiBDSCU+gOKUq MRnQTjkIYtD9BfouEaxFWnzbvs+i7usgMryipG/38/MBXx9d3PxIVzYDwQ1RrSkdnoU1 ysj6GWnVSo+GNLcpbgws6OvqtCT6HvbVnC/EGXibl/7nnRF/5jk7xMYT9PfRUn+TwJOG 2xFQ== 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=KORWMhnUBbgHwjYhqK1PttxgJfNlQ4Zi3Dop8SsLEok=; b=LynbR9q9jSEHQs7cf9UI03YScC+EdSkSvTtd6frptTK3sVhS6FQzvHDPC1E5ErupWr ioTQl08c7NhIaKoRj0GMfAhXlml4yGvij1Z5nbwYc68IkQn9cRA/Z9ORnstH5Ek0Rst2 TVMzjevR2kAJq2BAyUYKI+JXWUAxqErYBlq9/w8T4h+ZKZHtvOH3A5Blv6ttICYWE9D/ byAkqYIrulCSbSbmz2TX/csaeBEeurzmkB2YuF6OVPy9U5X97T4yoqnK2nZYkoYvLr9O 4LurPaAx910adp3cC9fAaE27Hwv1dU4zvY7aSbr2n1HSp3VMEQkPqrtrKEW70g9VHReC A2jw== X-Gm-Message-State: AOAM533HQaXn4uST+jUKKTOhQh56YJUDaZGJcnSL7qAy2AXUj2J6T8qs M6/YFFxOZlVpnJjrRybYFs4= X-Google-Smtp-Source: ABdhPJz279VjbUrenvZYbkVy2THGcHEWSHTmR1u4M1RC7w+19t5HALDnMLTpkJr3gdIUu9Lujqjd1Q== X-Received: by 2002:a05:6402:b17:: with SMTP id bm23mr4556787edb.173.1624293757343; Mon, 21 Jun 2021 09:42:37 -0700 (PDT) Received: from localhost.localdomain ([188.26.224.68]) by smtp.gmail.com with ESMTPSA id c23sm10931093eds.57.2021.06.21.09.42.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 09:42:37 -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 v2 net-next 4/6] net: dsa: calculate the largest_mtu across all ports in the tree Date: Mon, 21 Jun 2021 19:42:17 +0300 Message-Id: <20210621164219.3780244-5-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621164219.3780244-1-olteanv@gmail.com> References: <20210621164219.3780244-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.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 --- v1->v2: none 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 Mon Jun 21 16:42:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 465619 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, 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 320C1C4743C for ; Mon, 21 Jun 2021 17:03:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1EE8161042 for ; Mon, 21 Jun 2021 17:03:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230325AbhFURFf (ORCPT ); Mon, 21 Jun 2021 13:05:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230521AbhFURFN (ORCPT ); Mon, 21 Jun 2021 13:05:13 -0400 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 798B9C051C79 for ; Mon, 21 Jun 2021 09:42:39 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id t3so19848885edc.7 for ; Mon, 21 Jun 2021 09:42:39 -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=dLsFrDZSDjMyeL60R+oxQ/XXht01bUcev5VN438RqXs=; b=czkv4HsWeekbOHS4v1STrJzgoFUNpCS6A7E28uLIVK+GvYgzYCAHhFFZpuCIh15akz 7JhnfftI3ksf9Yz7sy7EuDsKdrpfSnfm295sAYgmCsvg+bTPCoYToOjBszGNpRD9YIN9 PJxXqmqkmcTn0aGeblQGkratDwJ+DJYlyBgfaJow9Yklb8LehrsRDWQl7K1CacnG2Y5w FFmT8jeRdixbEzxO93CzZqFqWpNupgVl7mmDG9TGRQj5XLvt2CGt5N8qyL7XjFb91HPX WADQoAJq6P8n0v4Lhg0ahtmJkO2g62S26cb8txaYaluYXT6wsQUYwXeWoAwtZYXPA/sV V3Vw== 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=dLsFrDZSDjMyeL60R+oxQ/XXht01bUcev5VN438RqXs=; b=XGTRqmc3QAHY8b3UJNrAiS70PjkBqFoeBWvP16P/BP31E1oBCWDxXXvq2AZcGHowMv ZskNQDom/dv1gXrAY21MUWpnUdc8NBvBmGQW97Bi/UlQkIiX7vKUtNZAfo117LPhGvX5 ZmRuAvw72Th8CDmQPDp7VdJP8di1ua8vjadIv1C3St5+5XSWwTKCVuuud86lKVwkMw2f w+nZYIiUEBfiql8RwSmWgKrtLixJTLzUPJzaFlXuiZ6Wl+r7Wi0JAgbi80QlA6KUtE13 SXoAQpr3i7c0m/IvMqo0vqKz9N673KXH1p7Xi60sXvoQzEjtwtA+SPZbq4CPWsThtTnG QeUg== X-Gm-Message-State: AOAM533YKKxbrQXrJ/cmS6DDOhUgyr1hR2Lr7P8IGVqPDD5a5DlB3y6n tE4idsDFmGTSYSDfH2SPtk4= X-Google-Smtp-Source: ABdhPJzmGEGpK+OMTVRkYDlr+G565frC7MNyqiuu2b5KT/AehHXoEi5YqCvH+qvoqQQqvtG2/p1FiA== X-Received: by 2002:a05:6402:176f:: with SMTP id da15mr5981230edb.334.1624293758119; Mon, 21 Jun 2021 09:42:38 -0700 (PDT) Received: from localhost.localdomain ([188.26.224.68]) by smtp.gmail.com with ESMTPSA id c23sm10931093eds.57.2021.06.21.09.42.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 09:42:37 -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 v2 net-next 5/6] net: dsa: targeted MTU notifiers should only match on one port Date: Mon, 21 Jun 2021 19:42:18 +0300 Message-Id: <20210621164219.3780244-6-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621164219.3780244-1-olteanv@gmail.com> References: <20210621164219.3780244-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.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 --- v1->v2: none 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 Mon Jun 21 16:42:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 465618 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, 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 08BA3C4743C for ; Mon, 21 Jun 2021 17:03:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E7A3B60FE3 for ; Mon, 21 Jun 2021 17:03:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231455AbhFURFk (ORCPT ); Mon, 21 Jun 2021 13:05:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231144AbhFURFO (ORCPT ); Mon, 21 Jun 2021 13:05:14 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C48CDC051C7A for ; Mon, 21 Jun 2021 09:42:40 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id gn32so2463842ejc.2 for ; Mon, 21 Jun 2021 09:42:40 -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=c315mCBT1tn5tr1zBb7HCFIpOOkGOXcsgmE+ZPvTa1s=; b=r7mt3CLbdiwUGtb1zNo9xySFpyDYew4x0mW3mwmgoUz0/ZE4s0T18cdp+Zz1G5H1gu MJ9FPMEU6/RqBz82uw5UAoNlBIobfjqfozYtFv7+Awtzke7ETTgoHc9YX+RIA6tatZn+ w2fRYbGY5+HchHRcpZy2g1ql85AAPzf5g7mvocAbNtgH8SBXjVCyvTD1FdlmIuOpqMWO ep14AIkThCJdJQTlQtpaFN6KL8KNktoICeV3BGYcyCXgl/x2yxcLkI+Ou9YAEw46RVY9 1EMWCCmKvPJQKhTxh9wrLnOg3TJUP4II68BSo+D8ZIS+ZLzdGwJbhBSjm57uwC04GN5O pYYg== 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=c315mCBT1tn5tr1zBb7HCFIpOOkGOXcsgmE+ZPvTa1s=; b=mu6FpabwXED+tT3jhw9AjPBr32ocJ904tvACalULBUGFAZ8RU9xnyaf6wW6TvSBKeu NNFSMtxqvAPrPUa5XmASSFccPM5f1st6e5LMm6P0wSd1O2DA80TRifBcO91664pigofw KA/hEyoLohLHVnn5pup0daaYMVhaoQuXZK13JR7JuBRdtN1cBqbDueD2NuZKC6jn7B8I dAbCCV7CrGQt+IzkOTeBZBdzSpIFPfRZONugC2NuRomfgRI+sWDMguXTN/m3Gv9OHzBT mI31rLVG8GhZVWnAAym1Z/q6apkl3pCBWU33wySqhac31CkZMQosNVjkI03BjhjzATJL BbhQ== X-Gm-Message-State: AOAM533g+/S9/5WtybA9VwSgdVIV3wBSCiyrbqGAwq1uVV5aMP8JdqMg f2XfaFFLA6PCONuBjmJDvog= X-Google-Smtp-Source: ABdhPJwNcO58NSFwmRVyT0+AjuqnMep7ZO5NrrykOFYFMizxIpsowmY0ujJfdyFEtYvSzuKcuqqE7w== X-Received: by 2002:a17:906:7742:: with SMTP id o2mr26292999ejn.284.1624293758950; Mon, 21 Jun 2021 09:42:38 -0700 (PDT) Received: from localhost.localdomain ([188.26.224.68]) by smtp.gmail.com with ESMTPSA id c23sm10931093eds.57.2021.06.21.09.42.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 09:42:38 -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 v2 net-next 6/6] net: dsa: remove cross-chip support from the MRP notifiers Date: Mon, 21 Jun 2021 19:42:19 +0300 Message-Id: <20210621164219.3780244-7-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621164219.3780244-1-olteanv@gmail.com> References: <20210621164219.3780244-1-olteanv@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.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 Reviewed-by: Horatiu Vultur --- v1->v2: remove unused variable "err" in dsa_switch_mrp_add_ring_role() net/dsa/switch.c | 55 ++++++------------------------------------------ 1 file changed, 7 insertions(+), 48 deletions(-) diff --git a/net/dsa/switch.c b/net/dsa/switch.c index 75f567390a6b..c1e5afafe633 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,18 @@ 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