From patchwork Mon Mar 8 15:04:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Waldekranz X-Patchwork-Id: 12122571 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 559AEC43381 for ; Mon, 8 Mar 2021 15:06:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 221BE6523D for ; Mon, 8 Mar 2021 15:06:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231342AbhCHPFh (ORCPT ); Mon, 8 Mar 2021 10:05:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231184AbhCHPFR (ORCPT ); Mon, 8 Mar 2021 10:05:17 -0500 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9ECC2C06174A for ; Mon, 8 Mar 2021 07:05:16 -0800 (PST) Received: by mail-lj1-x236.google.com with SMTP id u4so16491438ljh.6 for ; Mon, 08 Mar 2021 07:05:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=waldekranz-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:organization:content-transfer-encoding; bh=ngAdWgaFg04b00gupLmQJu+pOGUba6DEdcm73GzTXVo=; b=elRRa/SxF0nXc1JwXsyAhFdJtQZmrhCJjoJcHAVJ8jHVsOIeu25VqZ24ceMzIlLOG6 VHeYvrwGwLEFygelX9uPty21sDe+D6UsAcPEq9495Zhw4hu//jBLM9C+jG9iQ+xtUexO UphPknqSAd7g0tcLyfKM35OoUgTUAHLmJzBH379mB3pzmum1kNX3NtQc1cs2TIozdvt8 vn96thy4i/V9ghakKx50LRRRMhodPPf7GDeEBAOkPxD7zyHboc7L2Q2YnkdBqzZ/IAv+ MIqF8P/jcNJsRpECBQP3fnlonlA6PVKWJ+ih2kVG2NW2JFOYFMcLy07eXpGEbHjaH7Gg /SRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:organization:content-transfer-encoding; bh=ngAdWgaFg04b00gupLmQJu+pOGUba6DEdcm73GzTXVo=; b=QwTwCAPVjAjGGfrTb7V+UW6eAYFF0NeDqhj/ja2i2C14l/RAss6fgsxZtfq3291RnH BB/RPEhFwgZPlempYqLdJIlUmy4k9XDyESP2Jwbsd89NKhM87anC/1ZWV398gBR2knQM 7mqUYc2yeiIx65MB924HqiQTBbf0QEVqVuwbUNtdvELyQya3WxObK0Yw/kPrP9kZCWWX jg682l1vdkTsRuxM4n1RLZoMIswVAH3Y88b1UjYWummdNOmjmtNYejbqHWMQFmHRcNAL 7pTOB06kOWor6aV+ZJ/FdW5zcnnH9pZwJ47YyufxcADEiHrMUf1pZ6RRzo8S1pLb4o1H jLDQ== X-Gm-Message-State: AOAM532+ddfsgjP2EDdEHYG6chk9Y2KRwPZvY/tDqJm5e9hARTvtnDgy Rt55Rn1bHW8NFW1QZPoZGPbg7g== X-Google-Smtp-Source: ABdhPJwdRzuzbErc9ombuHQ5OOgDOnr4tVdVJUxEWyBblvH4E7+NRGpp8C0SXBjJQ5ELpQwc0yx5XQ== X-Received: by 2002:a2e:b0f2:: with SMTP id h18mr13661747ljl.396.1615215914576; Mon, 08 Mar 2021 07:05:14 -0800 (PST) Received: from veiron.westermo.com (static-193-12-47-89.cust.tele2.se. [193.12.47.89]) by smtp.gmail.com with ESMTPSA id i184sm1385696lfd.205.2021.03.08.07.05.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Mar 2021 07:05:13 -0800 (PST) From: Tobias Waldekranz To: davem@davemloft.net, kuba@kernel.org Cc: andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, olteanv@gmail.com, netdev@vger.kernel.org Subject: [PATCH net 1/2] net: dsa: Accept software VLANs for stacked interfaces Date: Mon, 8 Mar 2021 16:04:04 +0100 Message-Id: <20210308150405.3694678-2-tobias@waldekranz.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210308150405.3694678-1-tobias@waldekranz.com> References: <20210308150405.3694678-1-tobias@waldekranz.com> MIME-Version: 1.0 Organization: Westermo Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The dsa_slave_vlan_rx_{add,kill}_vid ndos are required for hardware that can not control VLAN filtering per port, rather it is a device global setting, in order to support VLAN uppers on non-bridged ports. For hardware that can control VLAN filtering per port, it is perfectly fine to fallback to software VLANs in this scenario. So, make sure that this "error" does not leave the DSA layer as vlan_add_vid does not know the meaning of it. The blamed commit removed this exemption by not advertising the feature if the driver did not implement VLAN offloading. But as we know see, the assumption that if a driver supports VLAN offloading, it will always use it, does not hold in certain edge cases. Fixes: 9b236d2a69da ("net: dsa: Advertise the VLAN offload netdev ability only if switch supports it") Signed-off-by: Tobias Waldekranz --- net/dsa/slave.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 992fcab4b552..64d330f138f5 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -1346,6 +1346,12 @@ static int dsa_slave_vlan_rx_add_vid(struct net_device *dev, __be16 proto, /* User port... */ ret = dsa_port_vlan_add(dp, &vlan, &extack); if (ret) { + if (ret == -EOPNOTSUPP) + /* Driver allows the configuration, but is not + * offloading it, which is fine by us. + */ + goto add_to_master; + if (extack._msg) netdev_err(dev, "%s\n", extack._msg); return ret; @@ -1360,6 +1366,7 @@ static int dsa_slave_vlan_rx_add_vid(struct net_device *dev, __be16 proto, return ret; } +add_to_master: return vlan_vid_add(master, proto, vid); } @@ -1379,7 +1386,7 @@ static int dsa_slave_vlan_rx_kill_vid(struct net_device *dev, __be16 proto, * ports which can be members of this VLAN as well. */ err = dsa_port_vlan_del(dp, &vlan); - if (err) + if (err && err != -EOPNOTSUPP) return err; vlan_vid_del(master, proto, vid); From patchwork Mon Mar 8 15:04:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Waldekranz X-Patchwork-Id: 12122569 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49160C433E9 for ; Mon, 8 Mar 2021 15:06:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 116A365235 for ; Mon, 8 Mar 2021 15:06:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231301AbhCHPFf (ORCPT ); Mon, 8 Mar 2021 10:05:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231190AbhCHPFR (ORCPT ); Mon, 8 Mar 2021 10:05:17 -0500 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B904BC06175F for ; Mon, 8 Mar 2021 07:05:16 -0800 (PST) Received: by mail-lf1-x12a.google.com with SMTP id d3so21423061lfg.10 for ; Mon, 08 Mar 2021 07:05:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=waldekranz-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:organization:content-transfer-encoding; bh=SCn1ePxBlfmDhRSXEliosEM6x87FZAygSIS1Ou6HoJM=; b=HNtq86TYDTnZhyiFvBrBScTdp6XP5GjH7vONWAY+Id2f1fCWt1AG5/HHzRNl2YZwZN Ys4JILU9otdZW5ZyVjAH1WyvKkj8rDPuaUYmdgxFovnLdXifRg3tRPSr5HwLcLHdnUlt 7bo4JG45Q01Sn7+quo8IRQar+IZ2BYZIeLwWLAB6BAc7WRCz+d7wUNJf+BsgiIxKxN6V P+3qitlPsjYRQXIrZvSgFOV3Wd7kffRtyyxi5FTR7CvmpbouvGIPrQoGwDiMAQmlrBiE Cpzdg28Th1PgsOA7hcMr/KWpUioiA55WO8DarKQSIIKE+VUfuMyFeVl4aT/rFYTdQQTF rqfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:organization:content-transfer-encoding; bh=SCn1ePxBlfmDhRSXEliosEM6x87FZAygSIS1Ou6HoJM=; b=hi++qEYiAj6O8JVC6hTi/f54eoMMiW5sz61W1C+kq6F0YaS3ylK8BAEdtt0wmYU7Ho iF7aCPreMBCMItj1Rt/Loo9a1SvRAxRU/JJKGFtCWk8UUA9topoJOFw0s2xxg1Udp3bM XGtoQqfNoZuwI2iq9WuPEqfFkRSpWu3bfMe0UwS+spZ3avxWDtogd8DbQjJvteOpTPe0 PvECn0dCtU1bDbzRc+kVlDViJ77FzdCCWUHOcvsTsRjZ7AbOk6KxV2EEWs1cnB95dt81 plKELjIgU0mAnRNkzYAs3uuuYCCrEt35eDOLxsQNHWYcmrTMZB1sarowRQ17/v4qy/ig W8Gw== X-Gm-Message-State: AOAM531Cq1WNPVYfb5h5s8VrsnbvimARWdJS7SZKtrAALagYHRhPD3Ii vFzLfxMLHv0Mv0wTqDJwHvgL4Q== X-Google-Smtp-Source: ABdhPJx9VQxz53L17ixe8hpQrCGLvm8wcSjfrS1lazELALJ7jo4KgiafOM1y88zv2R21LYGYho2F8w== X-Received: by 2002:a19:4d6:: with SMTP id 205mr15312643lfe.50.1615215915146; Mon, 08 Mar 2021 07:05:15 -0800 (PST) Received: from veiron.westermo.com (static-193-12-47-89.cust.tele2.se. [193.12.47.89]) by smtp.gmail.com with ESMTPSA id i184sm1385696lfd.205.2021.03.08.07.05.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Mar 2021 07:05:14 -0800 (PST) From: Tobias Waldekranz To: davem@davemloft.net, kuba@kernel.org Cc: andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, olteanv@gmail.com, netdev@vger.kernel.org Subject: [PATCH net 2/2] net: dsa: mv88e6xxx: Never apply VLANs on standalone ports to VTU Date: Mon, 8 Mar 2021 16:04:05 +0100 Message-Id: <20210308150405.3694678-3-tobias@waldekranz.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210308150405.3694678-1-tobias@waldekranz.com> References: <20210308150405.3694678-1-tobias@waldekranz.com> MIME-Version: 1.0 Organization: Westermo Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Standalone ports always have VLAN filtering (Port Control 2, 802.1Q Mode) disabled. So adding VIDs for any VLAN uppers to the VTU does not make one bit of difference on the ingress filtering, the CPU will still receive traffic from all VLANs. It does however needlessly consume a precious global resource, namely a VID. Therefore, we refine the requirement for accepting a VLAN on a port by mandating that the port must be offloading a bridge, in which case the device will actually make use of the filtering. Fixes: 061f6a505ac3 ("net: dsa: Add ndo_vlan_rx_{add, kill}_vid implementation") Signed-off-by: Tobias Waldekranz --- drivers/net/dsa/mv88e6xxx/chip.c | 40 ++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index 903d619e08ed..0ba44bcac7da 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -1618,6 +1618,38 @@ static int mv88e6xxx_port_vlan_filtering(struct dsa_switch *ds, int port, return err; } +static bool mv88e6xxx_port_offloads_vlans(struct dsa_switch *ds, int port) +{ + struct dsa_port *dp = dsa_to_port(ds, port); + struct mv88e6xxx_chip *chip = ds->priv; + + if (!mv88e6xxx_max_vid(chip)) + return false; + + /* There are roughly two scenarios in which VLANs may be added + * to a non-bridged port: + * (a) (b) br0 + * / + * vlan1 bond0 + * / / \ + * swp0 swp0 swp1 + * + * Either (a) a VLAN upper is added to a non-bridged port; or + * (b) a port is an indirect lower to a bridge via some + * stacked interface that is not offloaded, e.g. a bond in + * broadcast mode. + * + * We still get a callback in these cases as there are other + * DSA devices which cannot control VLAN filtering per + * port. mv88e6xxx is not one of those, so we can safely + * fallback to software VLANs. + */ + if (dsa_is_user_port(ds, port) && !dp->bridge_dev) + return false; + + return true; +} + static int mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port, const struct switchdev_obj_port_vlan *vlan) @@ -1625,9 +1657,6 @@ mv88e6xxx_port_vlan_prepare(struct dsa_switch *ds, int port, struct mv88e6xxx_chip *chip = ds->priv; int err; - if (!mv88e6xxx_max_vid(chip)) - return -EOPNOTSUPP; - /* If the requested port doesn't belong to the same bridge as the VLAN * members, do not support it (yet) and fallback to software VLAN. */ @@ -1993,6 +2022,9 @@ static int mv88e6xxx_port_vlan_add(struct dsa_switch *ds, int port, u8 member; int err; + if (!mv88e6xxx_port_offloads_vlans(ds, port)) + return -EOPNOTSUPP; + err = mv88e6xxx_port_vlan_prepare(ds, port, vlan); if (err) return err; @@ -2081,7 +2113,7 @@ static int mv88e6xxx_port_vlan_del(struct dsa_switch *ds, int port, int err = 0; u16 pvid; - if (!mv88e6xxx_max_vid(chip)) + if (!mv88e6xxx_port_offloads_vlans(ds, port)) return -EOPNOTSUPP; mv88e6xxx_reg_lock(chip);