From patchwork Sun Feb 14 15:53:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12087247 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 9C977C433E0 for ; Sun, 14 Feb 2021 15:55:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6A14864DDA for ; Sun, 14 Feb 2021 15:55:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229887AbhBNPzQ (ORCPT ); Sun, 14 Feb 2021 10:55:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229861AbhBNPzM (ORCPT ); Sun, 14 Feb 2021 10:55:12 -0500 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CA89C061756 for ; Sun, 14 Feb 2021 07:54:31 -0800 (PST) Received: by mail-ej1-x630.google.com with SMTP id lg21so7353047ejb.3 for ; Sun, 14 Feb 2021 07:54:31 -0800 (PST) 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=4uscKdj3e7dnMtPXmv9+QMMVBCYkWMXWgoYx5eWd1aM=; b=YLriXzAvAuOqD/v+i46xD2jTb4VVkH0LrnmPluR1jBrnWsQMDKMFIYUvaZS9e14hlI Ssa3c3QX5bZ8nyJsVIJXGckoUY+po0sD7k38yBMqSk8udS1XkM7gfGpKXDICn9tEJwBd IuIvi14+S9iIYvItHbg4TqARivCO6GNbtwX95XOPTCkTOTWD9TshC37Hs1DbP7tdPJS1 9K8O4PWAEUtypWxENPMd+CLxdnJZYjN0I76HZrstWBIKS47SZ8SiSHQw0aqu3jwkAaY+ 8wmc5Omv11QWEnqNFm4Bx01xn5ekMyh/cQUxsLoLhfg/o2qU6tSn4tzh0KEq7hKoSOZh /kHQ== 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=4uscKdj3e7dnMtPXmv9+QMMVBCYkWMXWgoYx5eWd1aM=; b=jZsJjbpg7qdJRo8eYNtCXVQpxutVqZQnXUlsiVTOQlnPHlnK0DQgse45/YQHZjJB3j KSqQrHbkPTcYsiXDj6s+mX4Iq/rupSkCChgifhlTdz55XNmVNT+lUx93sH9ZtKLI2xQ2 HGYBjT2UJVhlOVJ/htbi4Qk0KmdDZWPL6c1f+fNedKr4f93BROuBQZuqdypkucXrqHvV HrevxYxzs2SsA+4HTRKfbW9qTBSYAWk/OK8hIXYFbvWt7E37BPa7YAsIx6IyuRlyg5te qbq7iTuRdBq6+tXbNH5JH0N/Wzd6UiYW344nLZIvMZUGza0OYa79JnTLDnw9E1IrC4fO iUew== X-Gm-Message-State: AOAM532yYTtKP0Wuo5AHMvLSWOKV00OR38ZywBVcvQkFVqW7dbkehZ4d JDpwHopkppMc7w+8VCmzr74= X-Google-Smtp-Source: ABdhPJxz8n+j9cVliZ8WX7SUNdPlQpSCHzjOlg4Hn+FofJywPjQPtxcPAfGraje37YIUjK15yb/1EQ== X-Received: by 2002:a17:906:338f:: with SMTP id v15mr1451856eja.395.1613318069257; Sun, 14 Feb 2021 07:54:29 -0800 (PST) Received: from localhost.localdomain (5-12-227-87.residential.rdsnet.ro. [5.12.227.87]) by smtp.gmail.com with ESMTPSA id cn18sm8576003edb.66.2021.02.14.07.54.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Feb 2021 07:54:28 -0800 (PST) From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org Cc: Florian Fainelli , Andrew Lunn , Vivien Didelot , Kurt Kanzenbach , Woojung Huh , UNGLinuxDriver@microchip.com, Sean Wang , Landen Chao , Claudiu Manoil , Alexandre Belloni , George McCollister , Tobias Waldekranz , DENG Qingfang , Linus Walleij , Hauke Mehrtens , Rasmus Villemoes , Oleksij Rempel Subject: [PATCH net-next 1/4] net: dsa: don't offload switchdev objects on ports that don't offload the bridge Date: Sun, 14 Feb 2021 17:53:23 +0200 Message-Id: <20210214155326.1783266-2-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210214155326.1783266-1-olteanv@gmail.com> References: <20210214155326.1783266-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 Starting with commit 058102a6e9eb ("net: dsa: Link aggregation support"), DSA warns that certain configurations of upper interfaces are not offloaded to hardware. When a DSA port does not offload a LAG interface, the dp->lag_dev pointer is always NULL. However the same cannot be said about offloading a bridge: dp->bridge_dev will get populated regardless of whether the driver can put the port into the bridge's forwarding domain or not. Instead of silently returning 0 if the driver doesn't implement .port_bridge_join, return -EOPNOTSUPP instead, and print a message via netlink extack that the configuration was not offloaded to hardware. Now we can use the check whether dp->bridge_dev is NULL in order to avoid offloading at all switchdev attributes and objects for ports that don't even offload the basic operation of switching. Those can still do the required L2 forwarding using the bridge software datapath, but enabling any hardware features specific to the bridge such as address learning would just ask for problems. Signed-off-by: Vladimir Oltean Reviewed-by: Tobias Waldekranz --- net/dsa/dsa_priv.h | 2 ++ net/dsa/slave.c | 5 +++++ net/dsa/switch.c | 7 +++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h index f5949b39f6f7..7b0dd2d5f3f8 100644 --- a/net/dsa/dsa_priv.h +++ b/net/dsa/dsa_priv.h @@ -205,6 +205,8 @@ static inline bool dsa_port_offloads_netdev(struct dsa_port *dp, struct net_device *dev) { /* Switchdev offloading can be configured on: */ + if (!dp->bridge_dev) + return false; if (dev == dp->slave) /* DSA ports directly connected to a bridge, and event diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 8c9a41a7209a..94bce3596eb6 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -1922,6 +1922,11 @@ static int dsa_slave_changeupper(struct net_device *dev, err = dsa_port_bridge_join(dp, info->upper_dev); if (!err) dsa_bridge_mtu_normalization(dp); + if (err == -EOPNOTSUPP) { + NL_SET_ERR_MSG_MOD(info->info.extack, + "Offloading not supported"); + err = 0; + } err = notifier_from_errno(err); } else { dsa_port_bridge_leave(dp, info->upper_dev); diff --git a/net/dsa/switch.c b/net/dsa/switch.c index 1906179e59f7..4137716d0de5 100644 --- a/net/dsa/switch.c +++ b/net/dsa/switch.c @@ -88,9 +88,12 @@ static int dsa_switch_bridge_join(struct dsa_switch *ds, { struct dsa_switch_tree *dst = ds->dst; - if (dst->index == info->tree_index && ds->index == info->sw_index && - ds->ops->port_bridge_join) + if (dst->index == info->tree_index && ds->index == info->sw_index) { + if (!ds->ops->port_bridge_join) + return -EOPNOTSUPP; + return ds->ops->port_bridge_join(ds, info->port, info->br); + } if ((dst->index != info->tree_index || ds->index != info->sw_index) && ds->ops->crosschip_bridge_join) From patchwork Sun Feb 14 15:53:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12087251 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 B32FEC433E6 for ; Sun, 14 Feb 2021 15:55:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 82EB764DDD for ; Sun, 14 Feb 2021 15:55:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229892AbhBNPzV (ORCPT ); Sun, 14 Feb 2021 10:55:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229576AbhBNPzM (ORCPT ); Sun, 14 Feb 2021 10:55:12 -0500 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF2E2C0613D6 for ; Sun, 14 Feb 2021 07:54:31 -0800 (PST) Received: by mail-ej1-x62c.google.com with SMTP id n13so714078ejx.12 for ; Sun, 14 Feb 2021 07:54:31 -0800 (PST) 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=w8uuS5lGKgU6bYXJs+VHgIg/y+o1fOn0rgEbBEtu94M=; b=S2BqRbtyQ728yMQiEDxSeY/Elh3NdLR3q+tHCXKVjX8aNIqO4KZFGjEIqK0oMLPheu 7A2LOIw5czu91ToWoaNfarc7y3DvWbBYrguC1lAcFEiw8XTGdB5mECVpooLf9+4d9gtH wacGMwCkHBP+FXPfrPZdlw+lHLubGOioeU9hhgZ74dFRcAVFwEzsngUdW53lSwmBD9hB Mik66PGLgLWHjSIelx4heDl6GsbTsw8WtvlGJt+Q0hLzTeDbcU4nFl5zFohMqNhUXJuj nn+NpANsrsgYIfkEdU+v/daHlyWWPfEetpjjOnkJl6ylf4yZNvRgX7c3uqcoH+WBX03p ACig== 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=w8uuS5lGKgU6bYXJs+VHgIg/y+o1fOn0rgEbBEtu94M=; b=U6CiIbaU2BNoNLkdGPrXYEFVlPkQ1kQhzPZ3nGHyJR8UQHOj1VcD9EyxNvR+qbDv2W JsT2LAZtip/ydI+2z84iwWPFHitlpcFteqzclXJUngBCMkqbkvhkub0MaBwI4X1jY6dx DJsHawsUTmfOmF7sFP9v7iZ5BpJCW4VShbdTC3RyhbUSatOMC7/GxyrLwUImnd+LgQtY lREHx1u6jIUfu2DBnmk24MndEmMgyTFrjf1rVaWaffE3QnYwaG5wcoWUMz7d4G2woOQP NHxFy8Z+wJ04CZw6wFfvC2GPf+ky7/vyJ4VY59tb/fJn73azpRaK0SQkn5iI11CkRXzJ ANwg== X-Gm-Message-State: AOAM530jHibSRyBzoceoj5Cl9UVPdrsXx8zpeHJjOUy1JPEFpGzQ1rhR aoOYuYchCscnpr845UEIS40= X-Google-Smtp-Source: ABdhPJzAxQ83I9qzxZM1X5yH0TNKBT64B99VoyY28cF4kEwKtiW15t51mz+HJT3EetNJLfKAw8iTiw== X-Received: by 2002:a17:906:4c90:: with SMTP id q16mr12347463eju.49.1613318070550; Sun, 14 Feb 2021 07:54:30 -0800 (PST) Received: from localhost.localdomain (5-12-227-87.residential.rdsnet.ro. [5.12.227.87]) by smtp.gmail.com with ESMTPSA id cn18sm8576003edb.66.2021.02.14.07.54.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Feb 2021 07:54:30 -0800 (PST) From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org Cc: Florian Fainelli , Andrew Lunn , Vivien Didelot , Kurt Kanzenbach , Woojung Huh , UNGLinuxDriver@microchip.com, Sean Wang , Landen Chao , Claudiu Manoil , Alexandre Belloni , George McCollister , Tobias Waldekranz , DENG Qingfang , Linus Walleij , Hauke Mehrtens , Rasmus Villemoes , Oleksij Rempel Subject: [PATCH net-next 2/4] net: dsa: reject switchdev objects centrally from dsa_slave_port_obj_{add,del} Date: Sun, 14 Feb 2021 17:53:24 +0200 Message-Id: <20210214155326.1783266-3-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210214155326.1783266-1-olteanv@gmail.com> References: <20210214155326.1783266-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 dsa_port_offloads_netdev check is inside dsa_slave_vlan_{add,del}, but outside dsa_port_mdb_{add,del}. We can reduce the number of occurrences of dsa_port_offloads_netdev by checking only once, at the beginning of dsa_slave_port_obj_add and dsa_slave_port_obj_del. Signed-off-by: Vladimir Oltean Reviewed-by: Tobias Waldekranz --- net/dsa/slave.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 94bce3596eb6..8768b213c6e0 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -340,9 +340,6 @@ static int dsa_slave_vlan_add(struct net_device *dev, struct switchdev_obj_port_vlan vlan; int err; - if (!dsa_port_offloads_netdev(dp, obj->orig_dev)) - return -EOPNOTSUPP; - if (dsa_port_skip_vlan_configuration(dp)) { NL_SET_ERR_MSG_MOD(extack, "skipping configuration of VLAN"); return 0; @@ -385,10 +382,11 @@ static int dsa_slave_port_obj_add(struct net_device *dev, struct dsa_port *dp = dsa_slave_to_port(dev); int err; + if (!dsa_port_offloads_netdev(dp, obj->orig_dev)) + return -EOPNOTSUPP; + switch (obj->id) { case SWITCHDEV_OBJ_ID_PORT_MDB: - if (!dsa_port_offloads_netdev(dp, obj->orig_dev)) - return -EOPNOTSUPP; err = dsa_port_mdb_add(dp, SWITCHDEV_OBJ_PORT_MDB(obj)); break; case SWITCHDEV_OBJ_ID_HOST_MDB: @@ -416,9 +414,6 @@ static int dsa_slave_vlan_del(struct net_device *dev, struct switchdev_obj_port_vlan *vlan; int err; - if (!dsa_port_offloads_netdev(dp, obj->orig_dev)) - return -EOPNOTSUPP; - if (dsa_port_skip_vlan_configuration(dp)) return 0; @@ -442,10 +437,11 @@ static int dsa_slave_port_obj_del(struct net_device *dev, struct dsa_port *dp = dsa_slave_to_port(dev); int err; + if (!dsa_port_offloads_netdev(dp, obj->orig_dev)) + return -EOPNOTSUPP; + switch (obj->id) { case SWITCHDEV_OBJ_ID_PORT_MDB: - if (!dsa_port_offloads_netdev(dp, obj->orig_dev)) - return -EOPNOTSUPP; err = dsa_port_mdb_del(dp, SWITCHDEV_OBJ_PORT_MDB(obj)); break; case SWITCHDEV_OBJ_ID_HOST_MDB: From patchwork Sun Feb 14 15:53:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12087253 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 8F5E3C433DB for ; Sun, 14 Feb 2021 15:55:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 58C9D64DD8 for ; Sun, 14 Feb 2021 15:55:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229884AbhBNPza (ORCPT ); Sun, 14 Feb 2021 10:55:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229865AbhBNPzO (ORCPT ); Sun, 14 Feb 2021 10:55:14 -0500 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AAF3C061786 for ; Sun, 14 Feb 2021 07:54:33 -0800 (PST) Received: by mail-ed1-x52c.google.com with SMTP id v9so959563edw.8 for ; Sun, 14 Feb 2021 07:54:33 -0800 (PST) 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=cxB5vd8snAATgGMACotVhpSbwuBBRtJ2WkoyrEzEaWk=; b=WMgoyffU3MsRZpcA5WiCunkrG1GQH1Xr4cKJiMatlV/+rOZnYdrvoaSgO4cB9qVzWU c16Ywa4fQTmd8D3cinOMEjtGWrBcV5xIxSvE259GGxXKIBuMVOGansfR8OtMv7Oj9gyl rVN4tXkO/TAk5d1h9juggDViSHE6frsOXpJiZt5DS3H9tNdyvL1sKt1nVKLsaYM3NTN1 BDDQMl15b1soA2RYi91gByjgydUxfLypvX4s7J7slPip8d4cLrcyF8peq8SOeK0pTC7Z 51Kj22mY5IpvXzBoN/40QpMvsPoZDN+QZwYCCBtJonRe7+oPqEHXML/VeGmq7ngLrQ2p 6bJw== 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=cxB5vd8snAATgGMACotVhpSbwuBBRtJ2WkoyrEzEaWk=; b=S6Kkv8ZCCyW4ncW5ZwBzAYUJHJw6Y1uNdbSvHzSfeknRRDIwlkpQrIqenLVEeIXzua 2ooufg4wFX43VHHVDA+EPY8jxRG0EZ0NuJe15px33pD5Ppwupyb78mE7ErGE64SG8pb8 IHfyk54zzpvDuDuCkNIu6N/C9Qydp40+K+0eseb2+he3KsxJfe9OOwIDvDEr7sokIkMH aax6feYQiVDL2OcWu+j+jCcEGG24+q509goq+ztkZwpbCahhVnFGr3fKQfK/gIP3v7N5 R4/dIpuJ+itHnfg7/KNVcWEvgQGEsbgvyE5Wyv8u8eJmUsCraGk5GzufK3HsFqRFURad db2g== X-Gm-Message-State: AOAM532zGepS2/ZtEJT6NJd3MOL4iOj5loOFoS6bcVMvhSf7VHnsanNA i3U68cbZriR51vgxQS0gcjg= X-Google-Smtp-Source: ABdhPJyOMPvedFWyMS0qTRR3covtA1swEISLSkpBi1qANaVVU1QrPvpF5o8iKh1hRIqltVxHMj5DgA== X-Received: by 2002:a05:6402:27cf:: with SMTP id c15mr11788618ede.179.1613318071876; Sun, 14 Feb 2021 07:54:31 -0800 (PST) Received: from localhost.localdomain (5-12-227-87.residential.rdsnet.ro. [5.12.227.87]) by smtp.gmail.com with ESMTPSA id cn18sm8576003edb.66.2021.02.14.07.54.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Feb 2021 07:54:31 -0800 (PST) From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org Cc: Florian Fainelli , Andrew Lunn , Vivien Didelot , Kurt Kanzenbach , Woojung Huh , UNGLinuxDriver@microchip.com, Sean Wang , Landen Chao , Claudiu Manoil , Alexandre Belloni , George McCollister , Tobias Waldekranz , DENG Qingfang , Linus Walleij , Hauke Mehrtens , Rasmus Villemoes , Oleksij Rempel Subject: [PATCH net-next 3/4] net: dsa: return -EOPNOTSUPP if .port_lag_join is not implemented Date: Sun, 14 Feb 2021 17:53:25 +0200 Message-Id: <20210214155326.1783266-4-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210214155326.1783266-1-olteanv@gmail.com> References: <20210214155326.1783266-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 There is currently some provisioning for DSA to use the software fallback for link aggregation, but only if the .port_lag_join is implemented but it fails (for example because there are more link aggregation groups than the switch supports, or because the xmit hash policy cannot be done in hardware, or ...). But when .port_lag_join is not implemented at all, the DSA switch notifier returns zero and software fallback does not kick in. Change that. Signed-off-by: Vladimir Oltean Reviewed-by: Tobias Waldekranz --- net/dsa/switch.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/net/dsa/switch.c b/net/dsa/switch.c index 4137716d0de5..15b0c936ba01 100644 --- a/net/dsa/switch.c +++ b/net/dsa/switch.c @@ -203,9 +203,13 @@ static int dsa_switch_lag_change(struct dsa_switch *ds, static int dsa_switch_lag_join(struct dsa_switch *ds, struct dsa_notifier_lag_info *info) { - if (ds->index == info->sw_index && ds->ops->port_lag_join) + if (ds->index == info->sw_index) { + if (!ds->ops->port_lag_join) + return -EOPNOTSUPP; + return ds->ops->port_lag_join(ds, info->port, info->lag, info->info); + } if (ds->index != info->sw_index && ds->ops->crosschip_lag_join) return ds->ops->crosschip_lag_join(ds, info->sw_index, From patchwork Sun Feb 14 15:53:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12087255 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.8 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 BB170C433E0 for ; Sun, 14 Feb 2021 15:55:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 756FB64DCF for ; Sun, 14 Feb 2021 15:55:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229904AbhBNPzk (ORCPT ); Sun, 14 Feb 2021 10:55:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229873AbhBNPzP (ORCPT ); Sun, 14 Feb 2021 10:55:15 -0500 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BEDFC061788 for ; Sun, 14 Feb 2021 07:54:34 -0800 (PST) Received: by mail-ej1-x634.google.com with SMTP id n13so714240ejx.12 for ; Sun, 14 Feb 2021 07:54:34 -0800 (PST) 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=TeW8leO2RtVwcrBK4HHYpFHToiAaWhWUx4BN3kGRZR0=; b=KdnLLooEJBGFqYOPATupqYHXE/JvBi2ZKeokRaYfO4lCsXmHpHOe11Ui5GIYC7Jo31 PBS12wz5G/N8tcP4QqiH6R4Noe9f8MY/00+nhDoocnhr9HtlQNCwgfqoLDbzbK7dgx6C JAYFueua/V9vgooUOwHi/GR6Z/OxkyhvPOUOyJzAYAOVIkdberUg7fSeUor9x+tOxozp fjHphhxzih/edKzCwIRzek+LReYPNKuyme2iVGh5Jc2flGiL0TB2nnga+GKrAYzR5G7Y imoouBrzhmoWxrGfhSgqBuRGdolPp8eEs8Be4J+oWI78zfpH2kjsMhfjXa2J/bpaEQxm yAjg== 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=TeW8leO2RtVwcrBK4HHYpFHToiAaWhWUx4BN3kGRZR0=; b=V26yBtAfAUPCz4obqPVgEuexhhB1FTDm7dZUlxIMU5sYhsYJsDjb8UP8sB38+stqAe taqvnVk62+Vzk22uQMB7+LbFaqxTnPyIv/K/EhkC5C5vPM5pStJQIOk2JpYqh1037YPt Ke0kZEfB+KTBGYGVTIv1fcfv5P7uHYrIUJw49NV//uFqm68N7YUk3Pjfhq04+VxybjwB R8N6cODAhoLyzQxtKNG+bG02JvonTaFD2k09Wm06F3PZddhn3ZmTz/3+Rk6A/AE8/qaN ZreWQhhDJ51YJxiZtuMeAwg+kRosePQ/lAw6Q+zAAq3M3JUZod7T2QSg9fFO0NL/o5bU JEWQ== X-Gm-Message-State: AOAM530ZdJRfr4Y3HSl3uoVvPswNSbtByPeceTRcl6P66hoYu5Tw02+q RIraDmEESl7aG5DNV5jS9Eo= X-Google-Smtp-Source: ABdhPJxHIsKCitmWzsEVkeZl0ZXxMm5kC9+lfReeUJiw1hxJ0v+u/sd2CSd+ppZ3Z0nKXADA9Ri6xg== X-Received: by 2002:a17:907:aa9:: with SMTP id bz9mr11596374ejc.528.1613318073209; Sun, 14 Feb 2021 07:54:33 -0800 (PST) Received: from localhost.localdomain (5-12-227-87.residential.rdsnet.ro. [5.12.227.87]) by smtp.gmail.com with ESMTPSA id cn18sm8576003edb.66.2021.02.14.07.54.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Feb 2021 07:54:32 -0800 (PST) From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org Cc: Florian Fainelli , Andrew Lunn , Vivien Didelot , Kurt Kanzenbach , Woojung Huh , UNGLinuxDriver@microchip.com, Sean Wang , Landen Chao , Claudiu Manoil , Alexandre Belloni , George McCollister , Tobias Waldekranz , DENG Qingfang , Linus Walleij , Hauke Mehrtens , Rasmus Villemoes , Oleksij Rempel Subject: [PATCH net-next 4/4] net: dsa: don't set skb->offload_fwd_mark when not offloading the bridge Date: Sun, 14 Feb 2021 17:53:26 +0200 Message-Id: <20210214155326.1783266-5-olteanv@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210214155326.1783266-1-olteanv@gmail.com> References: <20210214155326.1783266-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 has gained the recent ability to deal gracefully with upper interfaces it cannot offload, such as the bridge, bonding or team drivers. When such uppers exist, the ports are still in standalone mode as far as the hardware is concerned. But when we deliver packets to the software bridge in order for that to do the forwarding, there is an unpleasant surprise in that the bridge will refuse to forward them. This is because we unconditionally set skb->offload_fwd_mark = true, meaning that the bridge thinks the frames were already forwarded in hardware by us. Since dp->bridge_dev is populated only when there is hardware offload for it, but not in the software fallback case, let's introduce a new helper that can be called from the tagger data path which sets the skb->offload_fwd_mark accordingly to zero when there is no hardware offload for bridging. This lets the bridge forward packets back to other interfaces of our switch, if needed. Signed-off-by: Vladimir Oltean Reviewed-by: Tobias Waldekranz --- net/dsa/dsa_priv.h | 14 ++++++++++++++ net/dsa/tag_brcm.c | 2 +- net/dsa/tag_dsa.c | 9 +++++---- net/dsa/tag_hellcreek.c | 2 +- net/dsa/tag_ksz.c | 2 +- net/dsa/tag_lan9303.c | 4 +++- net/dsa/tag_mtk.c | 2 +- net/dsa/tag_ocelot.c | 2 +- net/dsa/tag_ocelot_8021q.c | 2 +- net/dsa/tag_rtl4_a.c | 2 +- net/dsa/tag_sja1105.c | 4 ++-- net/dsa/tag_xrs700x.c | 3 +-- 12 files changed, 32 insertions(+), 16 deletions(-) diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h index 7b0dd2d5f3f8..4226ce1967d3 100644 --- a/net/dsa/dsa_priv.h +++ b/net/dsa/dsa_priv.h @@ -326,6 +326,20 @@ static inline struct sk_buff *dsa_untag_bridge_pvid(struct sk_buff *skb) return skb; } +/* If the ingress port offloads the bridge, we mark the frame as autonomously + * forwarded by hardware, so the software bridge doesn't forward in twice, back + * to us, because we already did. However, if we're in fallback mode and we do + * software bridging, we are not offloading it, therefore the dp->bridge_dev + * pointer is not populated, and flooding needs to be done by software (we are + * effectively operating in standalone ports mode). + */ +static inline void dsa_default_offload_fwd_mark(struct sk_buff *skb) +{ + struct dsa_port *dp = dsa_slave_to_port(skb->dev); + + skb->offload_fwd_mark = !!(dp->bridge_dev); +} + /* switch.c */ int dsa_switch_register_notifier(struct dsa_switch *ds); void dsa_switch_unregister_notifier(struct dsa_switch *ds); diff --git a/net/dsa/tag_brcm.c b/net/dsa/tag_brcm.c index e2577a7dcbca..a8880b3bb106 100644 --- a/net/dsa/tag_brcm.c +++ b/net/dsa/tag_brcm.c @@ -150,7 +150,7 @@ static struct sk_buff *brcm_tag_rcv_ll(struct sk_buff *skb, /* Remove Broadcom tag and update checksum */ skb_pull_rcsum(skb, BRCM_TAG_LEN); - skb->offload_fwd_mark = 1; + dsa_default_offload_fwd_mark(skb); return skb; } diff --git a/net/dsa/tag_dsa.c b/net/dsa/tag_dsa.c index 7e7b7decdf39..91f405b59f75 100644 --- a/net/dsa/tag_dsa.c +++ b/net/dsa/tag_dsa.c @@ -162,8 +162,8 @@ static struct sk_buff *dsa_xmit_ll(struct sk_buff *skb, struct net_device *dev, static struct sk_buff *dsa_rcv_ll(struct sk_buff *skb, struct net_device *dev, u8 extra) { + bool trap = false, trunk = false; int source_device, source_port; - bool trunk = false; enum dsa_code code; enum dsa_cmd cmd; u8 *dsa_header; @@ -174,8 +174,6 @@ static struct sk_buff *dsa_rcv_ll(struct sk_buff *skb, struct net_device *dev, cmd = dsa_header[0] >> 6; switch (cmd) { case DSA_CMD_FORWARD: - skb->offload_fwd_mark = 1; - trunk = !!(dsa_header[1] & 7); break; @@ -194,7 +192,6 @@ static struct sk_buff *dsa_rcv_ll(struct sk_buff *skb, struct net_device *dev, * device (like a bridge) that forwarding has * already been done by hardware. */ - skb->offload_fwd_mark = 1; break; case DSA_CODE_MGMT_TRAP: case DSA_CODE_IGMP_MLD_TRAP: @@ -202,6 +199,7 @@ static struct sk_buff *dsa_rcv_ll(struct sk_buff *skb, struct net_device *dev, /* Traps have, by definition, not been * forwarded by hardware, so don't mark them. */ + trap = true; break; default: /* Reserved code, this could be anything. Drop @@ -235,6 +233,9 @@ static struct sk_buff *dsa_rcv_ll(struct sk_buff *skb, struct net_device *dev, if (!skb->dev) return NULL; + if (!trap) + dsa_default_offload_fwd_mark(skb); + /* If the 'tagged' bit is set; convert the DSA tag to a 802.1Q * tag, and delete the ethertype (extra) if applicable. If the * 'tagged' bit is cleared; delete the DSA tag, and ethertype diff --git a/net/dsa/tag_hellcreek.c b/net/dsa/tag_hellcreek.c index a09805c8e1ab..c1ee6eefafe4 100644 --- a/net/dsa/tag_hellcreek.c +++ b/net/dsa/tag_hellcreek.c @@ -44,7 +44,7 @@ static struct sk_buff *hellcreek_rcv(struct sk_buff *skb, pskb_trim_rcsum(skb, skb->len - HELLCREEK_TAG_LEN); - skb->offload_fwd_mark = true; + dsa_default_offload_fwd_mark(skb); return skb; } diff --git a/net/dsa/tag_ksz.c b/net/dsa/tag_ksz.c index 4820dbcedfa2..8eee63a5b93b 100644 --- a/net/dsa/tag_ksz.c +++ b/net/dsa/tag_ksz.c @@ -24,7 +24,7 @@ static struct sk_buff *ksz_common_rcv(struct sk_buff *skb, pskb_trim_rcsum(skb, skb->len - len); - skb->offload_fwd_mark = true; + dsa_default_offload_fwd_mark(skb); return skb; } diff --git a/net/dsa/tag_lan9303.c b/net/dsa/tag_lan9303.c index aa1318dccaf0..3fd85139a3a6 100644 --- a/net/dsa/tag_lan9303.c +++ b/net/dsa/tag_lan9303.c @@ -115,7 +115,9 @@ static struct sk_buff *lan9303_rcv(struct sk_buff *skb, struct net_device *dev, skb_pull_rcsum(skb, 2 + 2); memmove(skb->data - ETH_HLEN, skb->data - (ETH_HLEN + LAN9303_TAG_LEN), 2 * ETH_ALEN); - skb->offload_fwd_mark = !(lan9303_tag1 & LAN9303_TAG_RX_TRAPPED_TO_CPU); + + if (!(lan9303_tag1 & LAN9303_TAG_RX_TRAPPED_TO_CPU)) + dsa_default_offload_fwd_mark(skb); return skb; } diff --git a/net/dsa/tag_mtk.c b/net/dsa/tag_mtk.c index 38dcdded74c0..08387fa37d17 100644 --- a/net/dsa/tag_mtk.c +++ b/net/dsa/tag_mtk.c @@ -97,7 +97,7 @@ static struct sk_buff *mtk_tag_rcv(struct sk_buff *skb, struct net_device *dev, /* Only unicast or broadcast frames are offloaded */ if (likely(!is_multicast_skb)) - skb->offload_fwd_mark = 1; + dsa_default_offload_fwd_mark(skb); return skb; } diff --git a/net/dsa/tag_ocelot.c b/net/dsa/tag_ocelot.c index 16a1afd5b8e1..7f0898569876 100644 --- a/net/dsa/tag_ocelot.c +++ b/net/dsa/tag_ocelot.c @@ -225,7 +225,7 @@ static struct sk_buff *ocelot_rcv(struct sk_buff *skb, */ return NULL; - skb->offload_fwd_mark = 1; + dsa_default_offload_fwd_mark(skb); skb->priority = qos_class; /* Ocelot switches copy frames unmodified to the CPU. However, it is diff --git a/net/dsa/tag_ocelot_8021q.c b/net/dsa/tag_ocelot_8021q.c index 8991ebf098a3..a9ad03626b2e 100644 --- a/net/dsa/tag_ocelot_8021q.c +++ b/net/dsa/tag_ocelot_8021q.c @@ -48,7 +48,7 @@ static struct sk_buff *ocelot_rcv(struct sk_buff *skb, if (!skb->dev) return NULL; - skb->offload_fwd_mark = 1; + dsa_default_offload_fwd_mark(skb); skb->priority = qos_class; return skb; diff --git a/net/dsa/tag_rtl4_a.c b/net/dsa/tag_rtl4_a.c index 2646abe5a69e..c942d8697ed8 100644 --- a/net/dsa/tag_rtl4_a.c +++ b/net/dsa/tag_rtl4_a.c @@ -101,7 +101,7 @@ static struct sk_buff *rtl4a_tag_rcv(struct sk_buff *skb, skb->data - ETH_HLEN - RTL4_A_HDR_LEN, 2 * ETH_ALEN); - skb->offload_fwd_mark = 1; + dsa_default_offload_fwd_mark(skb); return skb; } diff --git a/net/dsa/tag_sja1105.c b/net/dsa/tag_sja1105.c index 50496013cdb7..45cdf64f0e88 100644 --- a/net/dsa/tag_sja1105.c +++ b/net/dsa/tag_sja1105.c @@ -295,8 +295,6 @@ static struct sk_buff *sja1105_rcv(struct sk_buff *skb, is_link_local = sja1105_is_link_local(skb); is_meta = sja1105_is_meta_frame(skb); - skb->offload_fwd_mark = 1; - if (is_tagged) { /* Normal traffic path. */ skb_push_rcsum(skb, ETH_HLEN); @@ -339,6 +337,8 @@ static struct sk_buff *sja1105_rcv(struct sk_buff *skb, return NULL; } + dsa_default_offload_fwd_mark(skb); + if (subvlan) sja1105_decode_subvlan(skb, subvlan); diff --git a/net/dsa/tag_xrs700x.c b/net/dsa/tag_xrs700x.c index 858cdf9d2913..215ecceea89e 100644 --- a/net/dsa/tag_xrs700x.c +++ b/net/dsa/tag_xrs700x.c @@ -45,8 +45,7 @@ static struct sk_buff *xrs700x_rcv(struct sk_buff *skb, struct net_device *dev, if (pskb_trim_rcsum(skb, skb->len - 1)) return NULL; - /* Frame is forwarded by hardware, don't forward in software. */ - skb->offload_fwd_mark = 1; + dsa_default_offload_fwd_mark(skb); return skb; }